From 866c8d6db53f2bb9fc18b17b7a69662517a74dff Mon Sep 17 00:00:00 2001 From: Julian Davis Date: Sun, 13 Nov 2022 22:34:47 +0000 Subject: [PATCH] Fix pytest warnings about asyncio (#397) Turn on ayncio auto mode for pytest and remove the global async marking flag --- kasa/tests/conftest.py | 4 ---- kasa/tests/test_bulb.py | 1 - kasa/tests/test_cli.py | 2 +- kasa/tests/test_dimmer.py | 2 +- kasa/tests/test_discovery.py | 2 +- kasa/tests/test_emeter.py | 2 +- kasa/tests/test_lightstrip.py | 2 +- kasa/tests/test_plug.py | 2 +- kasa/tests/test_protocol.py | 1 - kasa/tests/test_smartdevice.py | 2 +- kasa/tests/test_strip.py | 2 +- pyproject.toml | 1 + 12 files changed, 9 insertions(+), 14 deletions(-) diff --git a/kasa/tests/conftest.py b/kasa/tests/conftest.py index faa5267e..fa925630 100644 --- a/kasa/tests/conftest.py +++ b/kasa/tests/conftest.py @@ -134,10 +134,6 @@ async def handle_turn_on(dev, turn_on): await dev.turn_off() -# to avoid adding this for each async function separately -pytestmark = pytest.mark.asyncio - - def device_for_file(model): for d in STRIPS: if d in model: diff --git a/kasa/tests/test_bulb.py b/kasa/tests/test_bulb.py index 9012f5b7..019afaf5 100644 --- a/kasa/tests/test_bulb.py +++ b/kasa/tests/test_bulb.py @@ -10,7 +10,6 @@ from .conftest import ( non_color_bulb, non_dimmable, non_variable_temp, - pytestmark, turn_on, variable_temp, ) diff --git a/kasa/tests/test_cli.py b/kasa/tests/test_cli.py index 6ea71326..762f0503 100644 --- a/kasa/tests/test_cli.py +++ b/kasa/tests/test_cli.py @@ -15,7 +15,7 @@ from kasa.cli import ( sysinfo, ) -from .conftest import handle_turn_on, pytestmark, turn_on +from .conftest import handle_turn_on, turn_on async def test_sysinfo(dev): diff --git a/kasa/tests/test_dimmer.py b/kasa/tests/test_dimmer.py index 96a1021a..b5e98b78 100644 --- a/kasa/tests/test_dimmer.py +++ b/kasa/tests/test_dimmer.py @@ -2,7 +2,7 @@ import pytest from kasa import SmartDimmer -from .conftest import dimmer, handle_turn_on, pytestmark, turn_on +from .conftest import dimmer, handle_turn_on, turn_on @dimmer diff --git a/kasa/tests/test_discovery.py b/kasa/tests/test_discovery.py index e83561a2..b941654b 100644 --- a/kasa/tests/test_discovery.py +++ b/kasa/tests/test_discovery.py @@ -6,7 +6,7 @@ import pytest # type: ignore # https://github.com/pytest-dev/pytest/issues/3342 from kasa import DeviceType, Discover, SmartDevice, SmartDeviceException, protocol from kasa.discover import _DiscoverProtocol -from .conftest import bulb, dimmer, lightstrip, plug, pytestmark, strip +from .conftest import bulb, dimmer, lightstrip, plug, strip @plug diff --git a/kasa/tests/test_emeter.py b/kasa/tests/test_emeter.py index b3d567dd..75375230 100644 --- a/kasa/tests/test_emeter.py +++ b/kasa/tests/test_emeter.py @@ -2,7 +2,7 @@ import pytest from kasa import EmeterStatus, SmartDeviceException -from .conftest import has_emeter, no_emeter, pytestmark +from .conftest import has_emeter, no_emeter from .newfakes import CURRENT_CONSUMPTION_SCHEMA diff --git a/kasa/tests/test_lightstrip.py b/kasa/tests/test_lightstrip.py index e53bb1f7..c90cedee 100644 --- a/kasa/tests/test_lightstrip.py +++ b/kasa/tests/test_lightstrip.py @@ -3,7 +3,7 @@ import pytest from kasa import DeviceType, SmartLightStrip from kasa.exceptions import SmartDeviceException -from .conftest import lightstrip, pytestmark +from .conftest import lightstrip @lightstrip diff --git a/kasa/tests/test_plug.py b/kasa/tests/test_plug.py index 3de3a146..e9704310 100644 --- a/kasa/tests/test_plug.py +++ b/kasa/tests/test_plug.py @@ -1,6 +1,6 @@ from kasa import DeviceType -from .conftest import plug, pytestmark +from .conftest import plug from .newfakes import PLUG_SCHEMA diff --git a/kasa/tests/test_protocol.py b/kasa/tests/test_protocol.py index f8931c11..e540a9fb 100644 --- a/kasa/tests/test_protocol.py +++ b/kasa/tests/test_protocol.py @@ -8,7 +8,6 @@ import pytest from ..exceptions import SmartDeviceException from ..protocol import TPLinkSmartHomeProtocol -from .conftest import pytestmark @pytest.mark.parametrize("retry_count", [1, 3, 5]) diff --git a/kasa/tests/test_smartdevice.py b/kasa/tests/test_smartdevice.py index 9138a7e5..dd97b081 100644 --- a/kasa/tests/test_smartdevice.py +++ b/kasa/tests/test_smartdevice.py @@ -6,7 +6,7 @@ import pytest # type: ignore # https://github.com/pytest-dev/pytest/issues/3342 from kasa import SmartDeviceException from kasa.smartstrip import SmartStripPlug -from .conftest import handle_turn_on, has_emeter, no_emeter, pytestmark, turn_on +from .conftest import handle_turn_on, has_emeter, no_emeter, turn_on from .newfakes import PLUG_SCHEMA, TZ_SCHEMA, FakeTransportProtocol diff --git a/kasa/tests/test_strip.py b/kasa/tests/test_strip.py index 21a11e37..03199904 100644 --- a/kasa/tests/test_strip.py +++ b/kasa/tests/test_strip.py @@ -4,7 +4,7 @@ import pytest from kasa import SmartDeviceException, SmartStrip -from .conftest import handle_turn_on, pytestmark, strip, turn_on +from .conftest import handle_turn_on, strip, turn_on @strip diff --git a/pyproject.toml b/pyproject.toml index 688b80ab..476376d1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,6 +80,7 @@ verbose = 2 markers = [ "requires_dummy: test requires dummy data to pass, skipped on real devices", ] +asyncio_mode = "auto" [tool.doc8] paths = ["docs"]