diff --git a/cases/host_test.py b/cases/host_test.py index 59e5100..9ad28a1 100644 --- a/cases/host_test.py +++ b/cases/host_test.py @@ -42,7 +42,8 @@ class HostTest(base_test.BaseTestClass): # type: ignore[misc] dut: PandoraDevice ref: PandoraDevice - def setup_class(self) -> None: + @avatar.asynchronous + async def setup_class(self) -> None: self.devices = PandoraDevices(self) self.dut, self.ref, *_ = self.devices @@ -51,13 +52,16 @@ def setup_class(self) -> None: if isinstance(device, BumblePandoraDevice): device.config.setdefault('classic_enabled', True) + await asyncio.gather(self.dut.reset(), self.ref.reset()) + def teardown_class(self) -> None: if self.devices: self.devices.stop_all() @avatar.asynchronous - async def setup_test(self) -> None: # pytype: disable=wrong-arg-types - await asyncio.gather(self.dut.reset(), self.ref.reset()) + async def teardown_test(self) -> None: + if self.results.is_test_executed(self.current_test_info.name): # type: ignore + await asyncio.gather(self.dut.reset(), self.ref.reset()) @avatar.parameterized( (DISCOVERABLE_LIMITED,), diff --git a/cases/le_host_test.py b/cases/le_host_test.py index eb2f017..45ddf38 100644 --- a/cases/le_host_test.py +++ b/cases/le_host_test.py @@ -51,7 +51,8 @@ class LeHostTest(base_test.BaseTestClass): # type: ignore[misc] dut: PandoraDevice ref: PandoraDevice - def setup_class(self) -> None: + @avatar.asynchronous + async def setup_class(self) -> None: self.devices = PandoraDevices(self) self.dut, self.ref, *_ = self.devices @@ -60,13 +61,16 @@ def setup_class(self) -> None: if isinstance(device, BumblePandoraDevice): device.config.setdefault('classic_enabled', True) + await asyncio.gather(self.dut.reset(), self.ref.reset()) + def teardown_class(self) -> None: if self.devices: self.devices.stop_all() @avatar.asynchronous - async def setup_test(self) -> None: # pytype: disable=wrong-arg-types - await asyncio.gather(self.dut.reset(), self.ref.reset()) + async def teardown_test(self) -> None: + if self.results.is_test_executed(self.current_test_info.name): # type: ignore + await asyncio.gather(self.dut.reset(), self.ref.reset()) @avatar.parameterized( *itertools.product( diff --git a/cases/le_security_test.py b/cases/le_security_test.py index d28a92f..af7cac5 100644 --- a/cases/le_security_test.py +++ b/cases/le_security_test.py @@ -37,7 +37,8 @@ class LeSecurityTest(base_test.BaseTestClass): # type: ignore[misc] dut: PandoraDevice ref: PandoraDevice - def setup_class(self) -> None: + @avatar.asynchronous + async def setup_class(self) -> None: self.devices = PandoraDevices(self) self.dut, self.ref, *_ = self.devices @@ -46,13 +47,16 @@ def setup_class(self) -> None: if isinstance(device, BumblePandoraDevice): device.config.setdefault('classic_enabled', True) + await asyncio.gather(self.dut.reset(), self.ref.reset()) + def teardown_class(self) -> None: if self.devices: self.devices.stop_all() @avatar.asynchronous - async def setup_test(self) -> None: # pytype: disable=wrong-arg-types - await asyncio.gather(self.dut.reset(), self.ref.reset()) + async def teardown_test(self) -> None: + if self.results.is_test_executed(self.current_test_info.name): # type: ignore + await asyncio.gather(self.dut.reset(), self.ref.reset()) async def handle_pairing_events(self) -> NoReturn: ref_pairing_stream = self.ref.aio.security.OnPairing() diff --git a/cases/security_test.py b/cases/security_test.py index 4d23b0c..d3dc659 100644 --- a/cases/security_test.py +++ b/cases/security_test.py @@ -65,6 +65,11 @@ def teardown_class(self) -> None: if self.devices: self.devices.stop_all() + @avatar.asynchronous + async def teardown_test(self) -> None: + if self.results.is_test_executed(self.current_test_info.name): # type: ignore + await asyncio.gather(self.dut.reset(), self.ref.reset()) + @avatar.parameterized( *itertools.product( ('outgoing_connection', 'incoming_connection'), @@ -142,9 +147,6 @@ async def test_ssp( if not isinstance(self.ref, BumblePandoraDevice) and ref_io_capability != 'against_default_io_cap': raise signals.TestSkip('Unable to override IO capability on non Bumble device.') - # Factory reset both DUT and REF devices. - await asyncio.gather(self.dut.reset(), self.ref.reset()) - # Override REF IO capability if supported. if isinstance(self.ref, BumblePandoraDevice): io_capability = {