From 4e415e7eca2c28a49520a1209ea5d5f17e5f5a1a Mon Sep 17 00:00:00 2001 From: James Braza Date: Wed, 2 Oct 2024 14:26:53 -0700 Subject: [PATCH] Moved `reset_log_levels` to `usefixtures` (#517) --- tests/conftest.py | 4 ++-- tests/test_agents.py | 5 ++--- tests/test_clients.py | 8 ++++---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 4583266d..1f0ac16e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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: diff --git a/tests/test_agents.py b/tests/test_agents.py index 633b197f..910a2067 100644 --- a/tests/test_agents.py +++ b/tests/test_agents.py @@ -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 == [ diff --git a/tests/test_clients.py b/tests/test_clients.py index 282b27cd..ea2b69ab 100644 --- a/tests/test_clients.py +++ b/tests/test_clients.py @@ -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 @@ -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: