Skip to content

helper function for commands returning errors #544

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

Open
cecille opened this issue Apr 15, 2025 · 0 comments · May be fixed by project-chip/connectedhomeip#38799
Open

helper function for commands returning errors #544

cecille opened this issue Apr 15, 2025 · 0 comments · May be fixed by project-chip/connectedhomeip#38799
Assignees

Comments

@cecille
Copy link
Contributor

cecille commented Apr 15, 2025

There are a bunch of tests where this is done incorrectly. There are two correct patterns (one more mobly-ish than the other).

either:

try:
  do command
  assert.fail('unexpected success')
except ChipStackError as e:
  check expected error

or

with asserts.assert_raises(ChipStackError)
  do command and check error

BUT what we have in a bunch of tests is

try:
  do command
except ChipStackError as e:
  check expected error

which will pass the test if the command unexpected succeeds.

This is common enough that we should define a helper function to do it properly AND the tests need a scrub to make sure the incorrect pattern is not used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In progress
Development

Successfully merging a pull request may close this issue.

2 participants