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

Tests don't properly check the raised exception #10

Closed
ali1234 opened this issue Apr 27, 2021 · 0 comments · Fixed by #8
Closed

Tests don't properly check the raised exception #10

ali1234 opened this issue Apr 27, 2021 · 0 comments · Fixed by #8

Comments

@ali1234
Copy link
Contributor

ali1234 commented Apr 27, 2021

with self.assertRaises(EncoderInitException) as err:
self.encoder._init()
self.assertEqual(str(err), 'FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BLOCK_SIZE')

The third line here has no effect. If encoder._init() raises an exception (which we expect it to), all subsequent lines won't run at all.

ali1234 added a commit to ali1234/pyFLAC that referenced this issue Apr 27, 2021
An exception inside a with block will immediately exit that block.
That means any subsequent checks won't run. We can test the string
by using assertRaisesRegex.

Fixes sonos#10
@joetoddsonos joetoddsonos linked a pull request May 20, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant