Repository navigation
Run the two assertions that sit inside pytest.raises blocks - #924
Open
dylanpulver wants to merge 1 commit into
Open
dylanpulver wants to merge 1 commit into
dylanpulver wants to merge 1 commit into
Conversation
`test_convert_output_multiple_column_error` and `test_create_error_if_invalid_self_referential_foreign_keys` each put their assertion inside the `with pytest.raises(...)` block, after the call that raises, so neither has ever run. The body has to raise for the test to pass and an assert can only raise AssertionError, so the raiser always precedes the assertion. The effect is that `pytest.raises` pins the exception type while the message goes unchecked. Both assertions pass once they execute, so no expectation needed updating. Rewording either message now fails the matching test, where before this change both still passed. tests/test_convert.py and tests/test_create.py stay at 218 passed, 1 skipped. `black --check` and `flake8` are clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two tests put their assertion inside the
with pytest.raises(...)block, after the call that raises:Neither has ever run. The body has to raise for the test to pass, and an
assertcan only raiseAssertionError, so the raiser always precedes the assertion. The effect is thatpytest.raisespins the exception type while the message goes unchecked.The other one is
test_create_error_if_invalid_self_referential_foreign_keys, which checksex.value.args.Both assertions pass once they execute, so no expectation needed updating. To confirm they now bite, I reworded both messages in
sqlite_utils/db.pyand ran the pair:tests/test_convert.pyandtests/test_create.pystay at 218 passed, 1 skipped.black --checkandflake8are clean.Found with a static check for assertions that cannot execute inside a
pytest.raisesblock, and written with Claude Code; the numbers above are from running the suite.📚 Documentation preview 📚: https://sqlite-utils--924.org.readthedocs.build/en/924/