Skip to content

Commit

Permalink
Queen Attack - Improve clarity of errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanplusplus committed May 25, 2024
1 parent 9d7aba4 commit 01a3665
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions exercises/practice/queen-attack/.meta/example.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
class Queen:
def __init__(self, row, column):
if row < 0:
raise ValueError('row not positive')
raise ValueError('row is negative')
if not 0 <= row <= 7:
raise ValueError('row not on board')
if column < 0:
raise ValueError('column not positive')
raise ValueError('column is negative')
if not 0 <= column <= 7:
raise ValueError('column not on board')
self.row = row
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/queen-attack/queen_attack_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_queen_must_have_positive_row(self):
with self.assertRaises(ValueError) as err:
Queen(-2, 2)
self.assertEqual(type(err.exception), ValueError)
self.assertEqual(err.exception.args[0], "row not positive")
self.assertEqual(err.exception.args[0], "row is negative")

def test_queen_must_have_row_on_board(self):
with self.assertRaises(ValueError) as err:
Expand All @@ -30,7 +30,7 @@ def test_queen_must_have_positive_column(self):
with self.assertRaises(ValueError) as err:
Queen(2, -2)
self.assertEqual(type(err.exception), ValueError)
self.assertEqual(err.exception.args[0], "column not positive")
self.assertEqual(err.exception.args[0], "column is negative")

def test_queen_must_have_column_on_board(self):
with self.assertRaises(ValueError) as err:
Expand Down

0 comments on commit 01a3665

Please sign in to comment.