-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[Bowling] Exception-expecting tests pass themselves by accident #2839
Comments
🤖 🤖 Hi! 👋🏽 👋 Welcome to the Exercism Python Repo! Thank you for opening an issue! 🐍 🌈 ✨
◦ If you'd also like to make a PR to fix the issue, please have a quick look at the Pull Requests doc.
💛 💙 While you are here... If you decide to help out with other open issues, you have our gratitude 🙌 🙌🏽. |
(status:
I am currently working on learning how to fix, and then fixing, this bug :)Pull request submitted!)The following tests are supposed to be checking that they get an exception when they ask for the score when a game is incomplete for various reasons:
test_an_unstarted_game_cannot_be_scored
test_an_incomplete_game_cannot_be_scored
test_bonus_rolls_for_a_strike_in_the_last_frame_must_be_rolled_before_score_can_be_calculated
test_both_bonus_rolls_for_a_strike_in_the_last_frame_must_be_rolled_before_score_can_be_calculated
test_bonus_roll_for_a_spare_in_the_last_frame_must_be_rolled_before_score_can_be_calculated
However, all five of these tests make a call to
game.roll()
without passing any arguments.game.roll()
is supposed to be passed a number of pins on a roll; when that argument is missing, it raises a TypeError. Those five tests, which were expecting an exception to be raised, therefore pass - but the exception that was raised was nothing to do with the game being complete or incomplete (which the tests are supposed to be checking for); the exception was actually just a consequence of the malformed call to theroll
method.Comparing the Python test file with the Ruby test file for the same exercise shows that the Ruby ones call the
game.score
method, not thegame.roll
method, for those five tests, which indicates that the problem is actually in the Python test file generator (JinJa2 template), specifically this block of code (lines 7-10:In
error_case
type tests, there is no consideration of theproperty
field from the canonical-data.json file; so the tests that expect an exception to be raised are always generated withgame.roll()
with no arguments, and thus they always do generate exceptions, and thus they always pass, regardless of what the user has coded.Contrast with the corresponding code in the Ruby test file generator, lines 31-35, which correctly use the
property
field to decide which function call should be used for these tests.The text was updated successfully, but these errors were encountered: