Skip to content

Commit

Permalink
Moved reset_log_levels to usefixtures (#517)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesbraza authored Oct 2, 2024
1 parent 4fc6138 commit 4e415e7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ def stub_data_dir_w_near_dupes(stub_data_dir: Path, tmp_path: Path) -> Iterator[
shutil.rmtree(tmp_path, ignore_errors=True)


@pytest.fixture
def reset_log_levels(caplog):
@pytest.fixture(name="reset_log_levels")
def fixture_reset_log_levels(caplog) -> Iterator[None]:
logging.getLogger().setLevel(logging.DEBUG)

for name in logging.root.manager.loggerDict:
Expand Down
5 changes: 2 additions & 3 deletions tests/test_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,9 @@ async def test_get_directory_index(agent_test_settings: Settings) -> None:
mock_aadd.assert_not_awaited(), "Expected we didn't re-add files"


@pytest.mark.usefixtures("reset_log_levels")
@pytest.mark.asyncio
async def test_get_directory_index_w_manifest(
agent_test_settings: Settings, reset_log_levels, caplog # noqa: ARG001
) -> None:
async def test_get_directory_index_w_manifest(agent_test_settings: Settings) -> None:
agent_test_settings.agent.index.manifest_file = "stub_manifest.csv"
index = await get_directory_index(settings=agent_test_settings)
assert index.fields == [
Expand Down
8 changes: 4 additions & 4 deletions tests/test_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,9 @@ async def test_bad_init() -> None:


@pytest.mark.vcr
@pytest.mark.usefixtures("reset_log_levels")
@pytest.mark.asyncio
async def test_ensure_sequential_run(caplog, reset_log_levels) -> None: # noqa: ARG001
async def test_ensure_sequential_run(caplog) -> None:
caplog.set_level(logging.DEBUG)
# were using a DOI that is NOT in crossref, but running the crossref client first
# we will ensure that both are run sequentially
Expand Down Expand Up @@ -535,10 +536,9 @@ async def test_ensure_sequential_run(caplog, reset_log_levels) -> None: # noqa:


@pytest.mark.vcr
@pytest.mark.usefixtures("reset_log_levels")
@pytest.mark.asyncio
async def test_ensure_sequential_run_early_stop(
caplog, reset_log_levels # noqa: ARG001
) -> None:
async def test_ensure_sequential_run_early_stop(caplog) -> None:
caplog.set_level(logging.DEBUG)
# now we should stop after hitting s2
async with aiohttp.ClientSession() as session:
Expand Down

0 comments on commit 4e415e7

Please sign in to comment.