Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move reset from setup to teardown #33

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions cases/host_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reset on setup class isnt necessary

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't have a reset on the setup_class, then if the test is skipped and there is only one test then it's gonna hang for ever on the Pandora apk shutdown. Maybe we can do the reset in the teardown in the case we have only one test and it is skipped. What do you think ?


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,),
Expand Down
10 changes: 7 additions & 3 deletions cases/le_host_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above


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(
Expand Down
10 changes: 7 additions & 3 deletions cases/le_security_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above


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()
Expand Down
8 changes: 5 additions & 3 deletions cases/security_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ def teardown_class(self) -> None:
if self.devices:
self.devices.stop_all()

@avatar.asynchronous
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove the reset on setup_class as well ?

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'),
Expand Down Expand Up @@ -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 = {
Expand Down