From 27147443d1c37fea9872f2cd9b87c7c74702601e Mon Sep 17 00:00:00 2001 From: RNeilsen Date: Tue, 4 Jan 2022 16:13:06 +1100 Subject: [PATCH 1/2] Fix error_case test gen to check for 'score' prpty error_case tests were being generated with code that always raised exceptions regardless of the user's code; this was disguised as 'passing' tests since they were expecting an exception anyway. --- exercises/practice/bowling/.meta/template.j2 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/exercises/practice/bowling/.meta/template.j2 b/exercises/practice/bowling/.meta/template.j2 index bd420ad47e..8234dd1c5a 100644 --- a/exercises/practice/bowling/.meta/template.j2 +++ b/exercises/practice/bowling/.meta/template.j2 @@ -5,8 +5,13 @@ rolls = {{ input["previousRolls"] }} game = self.roll_new_game(rolls) {% if case is error_case -%} + {% set property = case["property"] -%} with self.assertRaisesWithMessage(Exception): + {% if property == 'score' -%} + game.score() + {% else -%} game.roll({{ input["roll"] }}) + {% endif -%} {% else -%} self.assertEqual(game.score(), {{ case["expected"] }}) {% endif %} From b2379f975a25839481805fd8e3367d15fe3f5ec8 Mon Sep 17 00:00:00 2001 From: BethanyG Date: Tue, 4 Jan 2022 16:07:11 -0800 Subject: [PATCH 2/2] Update bowling_test.py Regenerated test case file from new JinJa2 template. --- exercises/practice/bowling/bowling_test.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/exercises/practice/bowling/bowling_test.py b/exercises/practice/bowling/bowling_test.py index 971b8f71de..35b8113947 100644 --- a/exercises/practice/bowling/bowling_test.py +++ b/exercises/practice/bowling/bowling_test.py @@ -151,13 +151,13 @@ def test_an_unstarted_game_cannot_be_scored(self): rolls = [] game = self.roll_new_game(rolls) with self.assertRaisesWithMessage(Exception): - game.roll() + game.score() def test_an_incomplete_game_cannot_be_scored(self): rolls = [0, 0] game = self.roll_new_game(rolls) with self.assertRaisesWithMessage(Exception): - game.roll() + game.score() def test_cannot_roll_if_game_already_has_ten_frames(self): rolls = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] @@ -171,7 +171,7 @@ def test_bonus_rolls_for_a_strike_in_the_last_frame_must_be_rolled_before_score_ rolls = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10] game = self.roll_new_game(rolls) with self.assertRaisesWithMessage(Exception): - game.roll() + game.score() def test_both_bonus_rolls_for_a_strike_in_the_last_frame_must_be_rolled_before_score_can_be_calculated( self, @@ -179,7 +179,7 @@ def test_both_bonus_rolls_for_a_strike_in_the_last_frame_must_be_rolled_before_s rolls = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10] game = self.roll_new_game(rolls) with self.assertRaisesWithMessage(Exception): - game.roll() + game.score() def test_bonus_roll_for_a_spare_in_the_last_frame_must_be_rolled_before_score_can_be_calculated( self, @@ -187,7 +187,7 @@ def test_bonus_roll_for_a_spare_in_the_last_frame_must_be_rolled_before_score_ca rolls = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3] game = self.roll_new_game(rolls) with self.assertRaisesWithMessage(Exception): - game.roll() + game.score() def test_cannot_roll_after_bonus_roll_for_spare(self): rolls = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 2]