From 0ccdf7a57a06dbedfbafac5a80eb7ba98641f66d Mon Sep 17 00:00:00 2001 From: Yuxin Wang Date: Sun, 26 Nov 2023 19:14:44 -0500 Subject: [PATCH] Remove unnecessary pytest.mark.asyncio by using aysncio_mode = auto (#21) This PR removes unnecessary pytest asyncio markers by using `asyncio_mode=auto` configurations for the pytest-asyncio plugin such that aync tests are automatically discovered. This PR also specifies the minimum versions for pytest and pytest-asyncio for `asyncio_mode=auto` support. --- pyproject.toml | 8 ++++++-- tests/test_init.py | 2 -- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a07113c..fd2319e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,9 +17,9 @@ dependencies = [] [project.optional-dependencies] dev = [ - "pytest", + "pytest>=6.0", "pytest-cov", - "pytest-asyncio", + "pytest-asyncio>=0.17", ] [build-system] @@ -31,6 +31,10 @@ build-backend = "setuptools.build_meta" [tool.setuptools.packages.find] where = ["src"] +[tool.pytest.ini_options] +minversion = "6.0" +asyncio_mode = "auto" + [tool.black] line-length = 99 target-version = ["py38"] diff --git a/tests/test_init.py b/tests/test_init.py index a35af27..8729516 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -9,7 +9,6 @@ from . import PARSED_DICT, SAMPLE_STATUS -@pytest.mark.asyncio async def test_request_status(): """Test top-level API request_status.""" with patch( @@ -19,7 +18,6 @@ async def test_request_status(): mock_request_raw_status.assert_called_once_with("testhost", 4242) -@pytest.mark.asyncio async def test_request_raw_status(): """Test requesting raw status from apcupsd NIC.""" with patch("asyncio.open_connection") as mock_open_connection: