From 57832ae8523cb943fdd89a828d501ba7fde3ed4e Mon Sep 17 00:00:00 2001 From: Steven B <51370195+sdb9696@users.noreply.github.com> Date: Sat, 23 Nov 2024 10:52:05 +0000 Subject: [PATCH 1/4] Run tests with caplog in a single worker --- pyproject.toml | 2 +- tests/iot/modules/test_schedule.py | 1 + tests/smart/modules/test_firmware.py | 1 + tests/smart/modules/test_temperaturecontrol.py | 1 + tests/test_aestransport.py | 1 + tests/test_bulb.py | 1 + tests/test_childdevice.py | 1 + tests/test_device_factory.py | 2 ++ tests/test_discovery.py | 2 ++ tests/test_feature.py | 1 + tests/test_klapprotocol.py | 1 + tests/test_protocol.py | 2 ++ tests/test_smartdevice.py | 3 +++ tests/test_smartprotocol.py | 2 ++ tests/test_sslaestransport.py | 1 + 15 files changed, 21 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9fdc888d1..ea4b1de91 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -107,7 +107,7 @@ markers = [ asyncio_mode = "auto" asyncio_default_fixture_loop_scope = "function" timeout = 10 -addopts = "--disable-socket --allow-unix-socket" +addopts = "--disable-socket --allow-unix-socket --dist=loadgroup" [tool.doc8] paths = ["docs"] diff --git a/tests/iot/modules/test_schedule.py b/tests/iot/modules/test_schedule.py index 152aaac85..4a4ffdee6 100644 --- a/tests/iot/modules/test_schedule.py +++ b/tests/iot/modules/test_schedule.py @@ -7,6 +7,7 @@ @device_iot +@pytest.mark.xdist_group(name="caplog") def test_schedule(dev: Device, caplog: pytest.LogCaptureFixture): schedule = dev.modules.get(Module.IotSchedule) assert schedule diff --git a/tests/smart/modules/test_firmware.py b/tests/smart/modules/test_firmware.py index 0bc0a4eab..e3fe5bb36 100644 --- a/tests/smart/modules/test_firmware.py +++ b/tests/smart/modules/test_firmware.py @@ -90,6 +90,7 @@ async def test_update_available_without_cloud(dev: SmartDevice): ], ) @pytest.mark.requires_dummy +@pytest.mark.xdist_group(name="caplog") async def test_firmware_update( dev: SmartDevice, mocker: MockerFixture, diff --git a/tests/smart/modules/test_temperaturecontrol.py b/tests/smart/modules/test_temperaturecontrol.py index 2653c53e1..d47f19ee6 100644 --- a/tests/smart/modules/test_temperaturecontrol.py +++ b/tests/smart/modules/test_temperaturecontrol.py @@ -137,6 +137,7 @@ async def test_thermostat_mode(dev, mode, states, frost_protection): ), ], ) +@pytest.mark.xdist_group(name="caplog") async def test_thermostat_mode_warnings(dev, mode, states, msg, caplog): """Test thermostat modes that should log a warning.""" temp_module: TemperatureControl = dev.modules["TemperatureControl"] diff --git a/tests/test_aestransport.py b/tests/test_aestransport.py index 4c95289a3..64bc8d4e4 100644 --- a/tests/test_aestransport.py +++ b/tests/test_aestransport.py @@ -216,6 +216,7 @@ async def test_send(mocker, status_code, error_code, inner_error_code, expectati assert "result" in res +@pytest.mark.xdist_group(name="caplog") async def test_unencrypted_response(mocker, caplog): host = "127.0.0.1" mock_aes_device = MockAesDevice(host, 200, 0, 0, do_not_encrypt_response=True) diff --git a/tests/test_bulb.py b/tests/test_bulb.py index 4a547522f..3ae1328f6 100644 --- a/tests/test_bulb.py +++ b/tests/test_bulb.py @@ -232,6 +232,7 @@ async def test_set_color_temp_transition(dev: IotBulb, mocker): @variable_temp_iot +@pytest.mark.xdist_group(name="caplog") async def test_unknown_temp_range(dev: IotBulb, monkeypatch, caplog): monkeypatch.setitem(dev._sys_info, "model", "unknown bulb") light = dev.modules.get(Module.Light) diff --git a/tests/test_childdevice.py b/tests/test_childdevice.py index d734d82c0..1e525efb0 100644 --- a/tests/test_childdevice.py +++ b/tests/test_childdevice.py @@ -136,6 +136,7 @@ async def test_child_time(dev: Device, freezer: FrozenDateTimeFactory): assert child.time != fallback_time +@pytest.mark.xdist_group(name="caplog") async def test_child_device_type_unknown(caplog): """Test for device type when category is unknown.""" diff --git a/tests/test_device_factory.py b/tests/test_device_factory.py index a0f501c39..860037445 100644 --- a/tests/test_device_factory.py +++ b/tests/test_device_factory.py @@ -109,6 +109,7 @@ async def test_connect_custom_port(discovery_mock, mocker, custom_port): assert dev.port == custom_port or dev.port == default_port +@pytest.mark.xdist_group(name="caplog") async def test_connect_logs_connect_time( discovery_mock, caplog: pytest.LogCaptureFixture, @@ -192,6 +193,7 @@ async def test_device_types(dev: Device): assert dev.device_type == res +@pytest.mark.xdist_group(name="caplog") async def test_device_class_from_unknown_family(caplog): """Verify that unknown SMART devices yield a warning and fallback to SmartDevice.""" dummy_name = "SMART.foo" diff --git a/tests/test_discovery.py b/tests/test_discovery.py index 787dea0e0..7069e32f6 100644 --- a/tests/test_discovery.py +++ b/tests/test_discovery.py @@ -119,6 +119,7 @@ async def test_type_detection_lightstrip(dev: Device): assert d.device_type == DeviceType.LightStrip +@pytest.mark.xdist_group(name="caplog") async def test_type_unknown(caplog): invalid_info = {"system": {"get_sysinfo": {"type": "nosuchtype"}}} assert Discover._get_device_class(invalid_info) is IotPlug @@ -586,6 +587,7 @@ async def test_do_discover_external_cancel(mocker): await dp.wait_for_discovery_to_complete() +@pytest.mark.xdist_group(name="caplog") async def test_discovery_redaction(discovery_mock, caplog: pytest.LogCaptureFixture): """Test query sensitive info redaction.""" mac = "12:34:56:78:9A:BC" diff --git a/tests/test_feature.py b/tests/test_feature.py index 79560b1ae..46cdd116c 100644 --- a/tests/test_feature.py +++ b/tests/test_feature.py @@ -127,6 +127,7 @@ async def test_feature_action(mocker): mock_call_action.assert_called() +@pytest.mark.xdist_group(name="caplog") async def test_feature_choice_list(dummy_feature, caplog, mocker: MockerFixture): """Test the choice feature type.""" dummy_feature.type = Feature.Type.Choice diff --git a/tests/test_klapprotocol.py b/tests/test_klapprotocol.py index a1521ee4d..26d9f57a4 100644 --- a/tests/test_klapprotocol.py +++ b/tests/test_klapprotocol.py @@ -184,6 +184,7 @@ def _fail_one_less_than_retry_count(*_, **__): @pytest.mark.parametrize("log_level", [logging.WARNING, logging.DEBUG]) +@pytest.mark.xdist_group(name="caplog") async def test_protocol_logging(mocker, caplog, log_level): caplog.set_level(log_level) logging.getLogger("kasa").setLevel(log_level) diff --git a/tests/test_protocol.py b/tests/test_protocol.py index 767d0f102..09134e851 100644 --- a/tests/test_protocol.py +++ b/tests/test_protocol.py @@ -307,6 +307,7 @@ def aio_mock_writer(_, __): ids=("_deprecated_TPLinkSmartHomeProtocol", "IotProtocol-XorTransport"), ) @pytest.mark.parametrize("log_level", [logging.WARNING, logging.DEBUG]) +@pytest.mark.xdist_group(name="caplog") async def test_protocol_logging( mocker, caplog, log_level, protocol_class, transport_class, encryption_class ): @@ -685,6 +686,7 @@ def test_deprecated_protocol(): @device_iot +@pytest.mark.xdist_group(name="caplog") async def test_iot_queries_redaction(dev: IotDevice, caplog: pytest.LogCaptureFixture): """Test query sensitive info redaction.""" if isinstance(dev.protocol._transport, FakeIotTransport): diff --git a/tests/test_smartdevice.py b/tests/test_smartdevice.py index 9d5956dca..a89b1098d 100644 --- a/tests/test_smartdevice.py +++ b/tests/test_smartdevice.py @@ -27,6 +27,7 @@ @device_smart @pytest.mark.requires_dummy +@pytest.mark.xdist_group(name="caplog") async def test_try_get_response(dev: SmartDevice, caplog): mock_response: dict = { "get_device_info": SmartErrorCode.PARAMS_ERROR, @@ -143,6 +144,7 @@ async def test_update_module_queries(dev: SmartDevice, mocker: MockerFixture): @device_smart +@pytest.mark.xdist_group(name="caplog") async def test_update_module_update_delays( dev: SmartDevice, mocker: MockerFixture, @@ -203,6 +205,7 @@ async def test_update_module_update_delays( ], ) @device_smart +@pytest.mark.xdist_group(name="caplog") async def test_update_module_query_errors( dev: SmartDevice, mocker: MockerFixture, diff --git a/tests/test_smartprotocol.py b/tests/test_smartprotocol.py index 180fb6aa0..fce6cd070 100644 --- a/tests/test_smartprotocol.py +++ b/tests/test_smartprotocol.py @@ -54,6 +54,7 @@ async def test_smart_device_errors(dummy_protocol, mocker, error_code): @pytest.mark.parametrize("error_code", [-13333, 13333]) +@pytest.mark.xdist_group(name="caplog") async def test_smart_device_unknown_errors( dummy_protocol, mocker, error_code, caplog: pytest.LogCaptureFixture ): @@ -417,6 +418,7 @@ async def test_incomplete_list(mocker, caplog): @device_smart +@pytest.mark.xdist_group(name="caplog") async def test_smart_queries_redaction( dev: SmartDevice, caplog: pytest.LogCaptureFixture ): diff --git a/tests/test_sslaestransport.py b/tests/test_sslaestransport.py index 0d8fac9cf..6816fa35d 100644 --- a/tests/test_sslaestransport.py +++ b/tests/test_sslaestransport.py @@ -175,6 +175,7 @@ async def test_send(mocker): assert "result" in res +@pytest.mark.xdist_group(name="caplog") async def test_unencrypted_response(mocker, caplog): host = "127.0.0.1" mock_ssl_aes_device = MockSslAesDevice(host, do_not_encrypt_response=True) From b4389a83b7c0dbc6d2ea9807b7cce5119b553344 Mon Sep 17 00:00:00 2001 From: Steven B <51370195+sdb9696@users.noreply.github.com> Date: Sat, 23 Nov 2024 11:12:31 +0000 Subject: [PATCH 2/4] Add comment to pyproject.toml --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index ea4b1de91..f9dfbf875 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -107,6 +107,8 @@ markers = [ asyncio_mode = "auto" asyncio_default_fixture_loop_scope = "function" timeout = 10 +# dist=loadgroup enables grouping of tests into single worker. +# required as caplog doesn't play nicely with multiple workers. addopts = "--disable-socket --allow-unix-socket --dist=loadgroup" [tool.doc8] From 76ea9956db6e02e69e4d2cb7032f6457856cd448 Mon Sep 17 00:00:00 2001 From: Steven B <51370195+sdb9696@users.noreply.github.com> Date: Sat, 23 Nov 2024 12:07:45 +0000 Subject: [PATCH 3/4] Mark fixture centrally --- tests/conftest.py | 7 +++++++ tests/iot/modules/test_schedule.py | 1 - tests/smart/modules/test_firmware.py | 1 - tests/smart/modules/test_temperaturecontrol.py | 1 - tests/test_aestransport.py | 1 - tests/test_bulb.py | 1 - tests/test_childdevice.py | 1 - tests/test_device_factory.py | 2 -- tests/test_discovery.py | 2 -- tests/test_feature.py | 1 - tests/test_klapprotocol.py | 1 - tests/test_protocol.py | 2 -- tests/test_smartdevice.py | 3 --- tests/test_smartprotocol.py | 2 -- tests/test_sslaestransport.py | 1 - 15 files changed, 7 insertions(+), 20 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 3da689c5b..0cf982e88 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -36,6 +36,13 @@ async def handle_turn_on(dev, turn_on): await dev.turn_off() +@pytest.fixture +@pytest.mark.xdist_group(name="caplog") +def caplog(caplog: pytest.LogCaptureFixture) -> pytest.LogCaptureFixture: + """Foo.""" + return caplog + + @pytest.fixture def dummy_protocol(): """Return a smart protocol instance with a mocking-ready dummy transport.""" diff --git a/tests/iot/modules/test_schedule.py b/tests/iot/modules/test_schedule.py index 4a4ffdee6..152aaac85 100644 --- a/tests/iot/modules/test_schedule.py +++ b/tests/iot/modules/test_schedule.py @@ -7,7 +7,6 @@ @device_iot -@pytest.mark.xdist_group(name="caplog") def test_schedule(dev: Device, caplog: pytest.LogCaptureFixture): schedule = dev.modules.get(Module.IotSchedule) assert schedule diff --git a/tests/smart/modules/test_firmware.py b/tests/smart/modules/test_firmware.py index e3fe5bb36..0bc0a4eab 100644 --- a/tests/smart/modules/test_firmware.py +++ b/tests/smart/modules/test_firmware.py @@ -90,7 +90,6 @@ async def test_update_available_without_cloud(dev: SmartDevice): ], ) @pytest.mark.requires_dummy -@pytest.mark.xdist_group(name="caplog") async def test_firmware_update( dev: SmartDevice, mocker: MockerFixture, diff --git a/tests/smart/modules/test_temperaturecontrol.py b/tests/smart/modules/test_temperaturecontrol.py index d47f19ee6..2653c53e1 100644 --- a/tests/smart/modules/test_temperaturecontrol.py +++ b/tests/smart/modules/test_temperaturecontrol.py @@ -137,7 +137,6 @@ async def test_thermostat_mode(dev, mode, states, frost_protection): ), ], ) -@pytest.mark.xdist_group(name="caplog") async def test_thermostat_mode_warnings(dev, mode, states, msg, caplog): """Test thermostat modes that should log a warning.""" temp_module: TemperatureControl = dev.modules["TemperatureControl"] diff --git a/tests/test_aestransport.py b/tests/test_aestransport.py index 64bc8d4e4..4c95289a3 100644 --- a/tests/test_aestransport.py +++ b/tests/test_aestransport.py @@ -216,7 +216,6 @@ async def test_send(mocker, status_code, error_code, inner_error_code, expectati assert "result" in res -@pytest.mark.xdist_group(name="caplog") async def test_unencrypted_response(mocker, caplog): host = "127.0.0.1" mock_aes_device = MockAesDevice(host, 200, 0, 0, do_not_encrypt_response=True) diff --git a/tests/test_bulb.py b/tests/test_bulb.py index 3ae1328f6..4a547522f 100644 --- a/tests/test_bulb.py +++ b/tests/test_bulb.py @@ -232,7 +232,6 @@ async def test_set_color_temp_transition(dev: IotBulb, mocker): @variable_temp_iot -@pytest.mark.xdist_group(name="caplog") async def test_unknown_temp_range(dev: IotBulb, monkeypatch, caplog): monkeypatch.setitem(dev._sys_info, "model", "unknown bulb") light = dev.modules.get(Module.Light) diff --git a/tests/test_childdevice.py b/tests/test_childdevice.py index 1e525efb0..d734d82c0 100644 --- a/tests/test_childdevice.py +++ b/tests/test_childdevice.py @@ -136,7 +136,6 @@ async def test_child_time(dev: Device, freezer: FrozenDateTimeFactory): assert child.time != fallback_time -@pytest.mark.xdist_group(name="caplog") async def test_child_device_type_unknown(caplog): """Test for device type when category is unknown.""" diff --git a/tests/test_device_factory.py b/tests/test_device_factory.py index 860037445..a0f501c39 100644 --- a/tests/test_device_factory.py +++ b/tests/test_device_factory.py @@ -109,7 +109,6 @@ async def test_connect_custom_port(discovery_mock, mocker, custom_port): assert dev.port == custom_port or dev.port == default_port -@pytest.mark.xdist_group(name="caplog") async def test_connect_logs_connect_time( discovery_mock, caplog: pytest.LogCaptureFixture, @@ -193,7 +192,6 @@ async def test_device_types(dev: Device): assert dev.device_type == res -@pytest.mark.xdist_group(name="caplog") async def test_device_class_from_unknown_family(caplog): """Verify that unknown SMART devices yield a warning and fallback to SmartDevice.""" dummy_name = "SMART.foo" diff --git a/tests/test_discovery.py b/tests/test_discovery.py index 7069e32f6..787dea0e0 100644 --- a/tests/test_discovery.py +++ b/tests/test_discovery.py @@ -119,7 +119,6 @@ async def test_type_detection_lightstrip(dev: Device): assert d.device_type == DeviceType.LightStrip -@pytest.mark.xdist_group(name="caplog") async def test_type_unknown(caplog): invalid_info = {"system": {"get_sysinfo": {"type": "nosuchtype"}}} assert Discover._get_device_class(invalid_info) is IotPlug @@ -587,7 +586,6 @@ async def test_do_discover_external_cancel(mocker): await dp.wait_for_discovery_to_complete() -@pytest.mark.xdist_group(name="caplog") async def test_discovery_redaction(discovery_mock, caplog: pytest.LogCaptureFixture): """Test query sensitive info redaction.""" mac = "12:34:56:78:9A:BC" diff --git a/tests/test_feature.py b/tests/test_feature.py index 46cdd116c..79560b1ae 100644 --- a/tests/test_feature.py +++ b/tests/test_feature.py @@ -127,7 +127,6 @@ async def test_feature_action(mocker): mock_call_action.assert_called() -@pytest.mark.xdist_group(name="caplog") async def test_feature_choice_list(dummy_feature, caplog, mocker: MockerFixture): """Test the choice feature type.""" dummy_feature.type = Feature.Type.Choice diff --git a/tests/test_klapprotocol.py b/tests/test_klapprotocol.py index 26d9f57a4..a1521ee4d 100644 --- a/tests/test_klapprotocol.py +++ b/tests/test_klapprotocol.py @@ -184,7 +184,6 @@ def _fail_one_less_than_retry_count(*_, **__): @pytest.mark.parametrize("log_level", [logging.WARNING, logging.DEBUG]) -@pytest.mark.xdist_group(name="caplog") async def test_protocol_logging(mocker, caplog, log_level): caplog.set_level(log_level) logging.getLogger("kasa").setLevel(log_level) diff --git a/tests/test_protocol.py b/tests/test_protocol.py index 09134e851..767d0f102 100644 --- a/tests/test_protocol.py +++ b/tests/test_protocol.py @@ -307,7 +307,6 @@ def aio_mock_writer(_, __): ids=("_deprecated_TPLinkSmartHomeProtocol", "IotProtocol-XorTransport"), ) @pytest.mark.parametrize("log_level", [logging.WARNING, logging.DEBUG]) -@pytest.mark.xdist_group(name="caplog") async def test_protocol_logging( mocker, caplog, log_level, protocol_class, transport_class, encryption_class ): @@ -686,7 +685,6 @@ def test_deprecated_protocol(): @device_iot -@pytest.mark.xdist_group(name="caplog") async def test_iot_queries_redaction(dev: IotDevice, caplog: pytest.LogCaptureFixture): """Test query sensitive info redaction.""" if isinstance(dev.protocol._transport, FakeIotTransport): diff --git a/tests/test_smartdevice.py b/tests/test_smartdevice.py index a89b1098d..9d5956dca 100644 --- a/tests/test_smartdevice.py +++ b/tests/test_smartdevice.py @@ -27,7 +27,6 @@ @device_smart @pytest.mark.requires_dummy -@pytest.mark.xdist_group(name="caplog") async def test_try_get_response(dev: SmartDevice, caplog): mock_response: dict = { "get_device_info": SmartErrorCode.PARAMS_ERROR, @@ -144,7 +143,6 @@ async def test_update_module_queries(dev: SmartDevice, mocker: MockerFixture): @device_smart -@pytest.mark.xdist_group(name="caplog") async def test_update_module_update_delays( dev: SmartDevice, mocker: MockerFixture, @@ -205,7 +203,6 @@ async def test_update_module_update_delays( ], ) @device_smart -@pytest.mark.xdist_group(name="caplog") async def test_update_module_query_errors( dev: SmartDevice, mocker: MockerFixture, diff --git a/tests/test_smartprotocol.py b/tests/test_smartprotocol.py index fce6cd070..180fb6aa0 100644 --- a/tests/test_smartprotocol.py +++ b/tests/test_smartprotocol.py @@ -54,7 +54,6 @@ async def test_smart_device_errors(dummy_protocol, mocker, error_code): @pytest.mark.parametrize("error_code", [-13333, 13333]) -@pytest.mark.xdist_group(name="caplog") async def test_smart_device_unknown_errors( dummy_protocol, mocker, error_code, caplog: pytest.LogCaptureFixture ): @@ -418,7 +417,6 @@ async def test_incomplete_list(mocker, caplog): @device_smart -@pytest.mark.xdist_group(name="caplog") async def test_smart_queries_redaction( dev: SmartDevice, caplog: pytest.LogCaptureFixture ): diff --git a/tests/test_sslaestransport.py b/tests/test_sslaestransport.py index 6816fa35d..0d8fac9cf 100644 --- a/tests/test_sslaestransport.py +++ b/tests/test_sslaestransport.py @@ -175,7 +175,6 @@ async def test_send(mocker): assert "result" in res -@pytest.mark.xdist_group(name="caplog") async def test_unencrypted_response(mocker, caplog): host = "127.0.0.1" mock_ssl_aes_device = MockSslAesDevice(host, do_not_encrypt_response=True) From 39e3982c7edf809b0bd9816f88ddd81a2e93618e Mon Sep 17 00:00:00 2001 From: Steven B <51370195+sdb9696@users.noreply.github.com> Date: Sat, 23 Nov 2024 12:14:41 +0000 Subject: [PATCH 4/4] Revert "Mark fixture centrally" This reverts commit 76ea9956db6e02e69e4d2cb7032f6457856cd448. --- tests/conftest.py | 7 ------- tests/iot/modules/test_schedule.py | 1 + tests/smart/modules/test_firmware.py | 1 + tests/smart/modules/test_temperaturecontrol.py | 1 + tests/test_aestransport.py | 1 + tests/test_bulb.py | 1 + tests/test_childdevice.py | 1 + tests/test_device_factory.py | 2 ++ tests/test_discovery.py | 2 ++ tests/test_feature.py | 1 + tests/test_klapprotocol.py | 1 + tests/test_protocol.py | 2 ++ tests/test_smartdevice.py | 3 +++ tests/test_smartprotocol.py | 2 ++ tests/test_sslaestransport.py | 1 + 15 files changed, 20 insertions(+), 7 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 0cf982e88..3da689c5b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -36,13 +36,6 @@ async def handle_turn_on(dev, turn_on): await dev.turn_off() -@pytest.fixture -@pytest.mark.xdist_group(name="caplog") -def caplog(caplog: pytest.LogCaptureFixture) -> pytest.LogCaptureFixture: - """Foo.""" - return caplog - - @pytest.fixture def dummy_protocol(): """Return a smart protocol instance with a mocking-ready dummy transport.""" diff --git a/tests/iot/modules/test_schedule.py b/tests/iot/modules/test_schedule.py index 152aaac85..4a4ffdee6 100644 --- a/tests/iot/modules/test_schedule.py +++ b/tests/iot/modules/test_schedule.py @@ -7,6 +7,7 @@ @device_iot +@pytest.mark.xdist_group(name="caplog") def test_schedule(dev: Device, caplog: pytest.LogCaptureFixture): schedule = dev.modules.get(Module.IotSchedule) assert schedule diff --git a/tests/smart/modules/test_firmware.py b/tests/smart/modules/test_firmware.py index 0bc0a4eab..e3fe5bb36 100644 --- a/tests/smart/modules/test_firmware.py +++ b/tests/smart/modules/test_firmware.py @@ -90,6 +90,7 @@ async def test_update_available_without_cloud(dev: SmartDevice): ], ) @pytest.mark.requires_dummy +@pytest.mark.xdist_group(name="caplog") async def test_firmware_update( dev: SmartDevice, mocker: MockerFixture, diff --git a/tests/smart/modules/test_temperaturecontrol.py b/tests/smart/modules/test_temperaturecontrol.py index 2653c53e1..d47f19ee6 100644 --- a/tests/smart/modules/test_temperaturecontrol.py +++ b/tests/smart/modules/test_temperaturecontrol.py @@ -137,6 +137,7 @@ async def test_thermostat_mode(dev, mode, states, frost_protection): ), ], ) +@pytest.mark.xdist_group(name="caplog") async def test_thermostat_mode_warnings(dev, mode, states, msg, caplog): """Test thermostat modes that should log a warning.""" temp_module: TemperatureControl = dev.modules["TemperatureControl"] diff --git a/tests/test_aestransport.py b/tests/test_aestransport.py index 4c95289a3..64bc8d4e4 100644 --- a/tests/test_aestransport.py +++ b/tests/test_aestransport.py @@ -216,6 +216,7 @@ async def test_send(mocker, status_code, error_code, inner_error_code, expectati assert "result" in res +@pytest.mark.xdist_group(name="caplog") async def test_unencrypted_response(mocker, caplog): host = "127.0.0.1" mock_aes_device = MockAesDevice(host, 200, 0, 0, do_not_encrypt_response=True) diff --git a/tests/test_bulb.py b/tests/test_bulb.py index 4a547522f..3ae1328f6 100644 --- a/tests/test_bulb.py +++ b/tests/test_bulb.py @@ -232,6 +232,7 @@ async def test_set_color_temp_transition(dev: IotBulb, mocker): @variable_temp_iot +@pytest.mark.xdist_group(name="caplog") async def test_unknown_temp_range(dev: IotBulb, monkeypatch, caplog): monkeypatch.setitem(dev._sys_info, "model", "unknown bulb") light = dev.modules.get(Module.Light) diff --git a/tests/test_childdevice.py b/tests/test_childdevice.py index d734d82c0..1e525efb0 100644 --- a/tests/test_childdevice.py +++ b/tests/test_childdevice.py @@ -136,6 +136,7 @@ async def test_child_time(dev: Device, freezer: FrozenDateTimeFactory): assert child.time != fallback_time +@pytest.mark.xdist_group(name="caplog") async def test_child_device_type_unknown(caplog): """Test for device type when category is unknown.""" diff --git a/tests/test_device_factory.py b/tests/test_device_factory.py index a0f501c39..860037445 100644 --- a/tests/test_device_factory.py +++ b/tests/test_device_factory.py @@ -109,6 +109,7 @@ async def test_connect_custom_port(discovery_mock, mocker, custom_port): assert dev.port == custom_port or dev.port == default_port +@pytest.mark.xdist_group(name="caplog") async def test_connect_logs_connect_time( discovery_mock, caplog: pytest.LogCaptureFixture, @@ -192,6 +193,7 @@ async def test_device_types(dev: Device): assert dev.device_type == res +@pytest.mark.xdist_group(name="caplog") async def test_device_class_from_unknown_family(caplog): """Verify that unknown SMART devices yield a warning and fallback to SmartDevice.""" dummy_name = "SMART.foo" diff --git a/tests/test_discovery.py b/tests/test_discovery.py index 787dea0e0..7069e32f6 100644 --- a/tests/test_discovery.py +++ b/tests/test_discovery.py @@ -119,6 +119,7 @@ async def test_type_detection_lightstrip(dev: Device): assert d.device_type == DeviceType.LightStrip +@pytest.mark.xdist_group(name="caplog") async def test_type_unknown(caplog): invalid_info = {"system": {"get_sysinfo": {"type": "nosuchtype"}}} assert Discover._get_device_class(invalid_info) is IotPlug @@ -586,6 +587,7 @@ async def test_do_discover_external_cancel(mocker): await dp.wait_for_discovery_to_complete() +@pytest.mark.xdist_group(name="caplog") async def test_discovery_redaction(discovery_mock, caplog: pytest.LogCaptureFixture): """Test query sensitive info redaction.""" mac = "12:34:56:78:9A:BC" diff --git a/tests/test_feature.py b/tests/test_feature.py index 79560b1ae..46cdd116c 100644 --- a/tests/test_feature.py +++ b/tests/test_feature.py @@ -127,6 +127,7 @@ async def test_feature_action(mocker): mock_call_action.assert_called() +@pytest.mark.xdist_group(name="caplog") async def test_feature_choice_list(dummy_feature, caplog, mocker: MockerFixture): """Test the choice feature type.""" dummy_feature.type = Feature.Type.Choice diff --git a/tests/test_klapprotocol.py b/tests/test_klapprotocol.py index a1521ee4d..26d9f57a4 100644 --- a/tests/test_klapprotocol.py +++ b/tests/test_klapprotocol.py @@ -184,6 +184,7 @@ def _fail_one_less_than_retry_count(*_, **__): @pytest.mark.parametrize("log_level", [logging.WARNING, logging.DEBUG]) +@pytest.mark.xdist_group(name="caplog") async def test_protocol_logging(mocker, caplog, log_level): caplog.set_level(log_level) logging.getLogger("kasa").setLevel(log_level) diff --git a/tests/test_protocol.py b/tests/test_protocol.py index 767d0f102..09134e851 100644 --- a/tests/test_protocol.py +++ b/tests/test_protocol.py @@ -307,6 +307,7 @@ def aio_mock_writer(_, __): ids=("_deprecated_TPLinkSmartHomeProtocol", "IotProtocol-XorTransport"), ) @pytest.mark.parametrize("log_level", [logging.WARNING, logging.DEBUG]) +@pytest.mark.xdist_group(name="caplog") async def test_protocol_logging( mocker, caplog, log_level, protocol_class, transport_class, encryption_class ): @@ -685,6 +686,7 @@ def test_deprecated_protocol(): @device_iot +@pytest.mark.xdist_group(name="caplog") async def test_iot_queries_redaction(dev: IotDevice, caplog: pytest.LogCaptureFixture): """Test query sensitive info redaction.""" if isinstance(dev.protocol._transport, FakeIotTransport): diff --git a/tests/test_smartdevice.py b/tests/test_smartdevice.py index 9d5956dca..a89b1098d 100644 --- a/tests/test_smartdevice.py +++ b/tests/test_smartdevice.py @@ -27,6 +27,7 @@ @device_smart @pytest.mark.requires_dummy +@pytest.mark.xdist_group(name="caplog") async def test_try_get_response(dev: SmartDevice, caplog): mock_response: dict = { "get_device_info": SmartErrorCode.PARAMS_ERROR, @@ -143,6 +144,7 @@ async def test_update_module_queries(dev: SmartDevice, mocker: MockerFixture): @device_smart +@pytest.mark.xdist_group(name="caplog") async def test_update_module_update_delays( dev: SmartDevice, mocker: MockerFixture, @@ -203,6 +205,7 @@ async def test_update_module_update_delays( ], ) @device_smart +@pytest.mark.xdist_group(name="caplog") async def test_update_module_query_errors( dev: SmartDevice, mocker: MockerFixture, diff --git a/tests/test_smartprotocol.py b/tests/test_smartprotocol.py index 180fb6aa0..fce6cd070 100644 --- a/tests/test_smartprotocol.py +++ b/tests/test_smartprotocol.py @@ -54,6 +54,7 @@ async def test_smart_device_errors(dummy_protocol, mocker, error_code): @pytest.mark.parametrize("error_code", [-13333, 13333]) +@pytest.mark.xdist_group(name="caplog") async def test_smart_device_unknown_errors( dummy_protocol, mocker, error_code, caplog: pytest.LogCaptureFixture ): @@ -417,6 +418,7 @@ async def test_incomplete_list(mocker, caplog): @device_smart +@pytest.mark.xdist_group(name="caplog") async def test_smart_queries_redaction( dev: SmartDevice, caplog: pytest.LogCaptureFixture ): diff --git a/tests/test_sslaestransport.py b/tests/test_sslaestransport.py index 0d8fac9cf..6816fa35d 100644 --- a/tests/test_sslaestransport.py +++ b/tests/test_sslaestransport.py @@ -175,6 +175,7 @@ async def test_send(mocker): assert "result" in res +@pytest.mark.xdist_group(name="caplog") async def test_unencrypted_response(mocker, caplog): host = "127.0.0.1" mock_ssl_aes_device = MockSslAesDevice(host, do_not_encrypt_response=True)