Skip to content

Commit bd5bb3d

Browse files
committed
Refactored get_row to use range_vals
1 parent 0ecba1b commit bd5bb3d

File tree

2 files changed

+1
-30
lines changed

2 files changed

+1
-30
lines changed

Application/Casino/Games/TicTacToe/TicTacToe.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,7 @@ def is_cell_empty(self, row: int, col: int) -> bool:
5151
return self.game_board[row][col] == " "
5252

5353
def get_row(self) -> int:
54-
row = self.console.get_integer_input("Enter row number (1-3)")
55-
56-
while row < 1 or row > 3:
57-
self.console.print_error("Row number must be between 1 and 3")
58-
row = self.console.get_integer_input("Enter row number (1-3)")
59-
60-
return row
54+
return self.console.get_integer_input("Enter row number (1-3)", range_vals=[1, 3])
6155

6256
def get_col(self) -> int:
6357
col = self.console.get_integer_input("Enter column number (1-3)")

Tests/Casino/Games/test_TicTacToe.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -165,29 +165,6 @@ def test_get_row_first_try(self, mock_input):
165165
actual: int = self.game.get_row()
166166
self.assertEqual(expected, actual)
167167

168-
@patch(f"{IOCONSOLE_PATH}.get_integer_input", side_effect=[0, 1])
169-
def test_get_row_second_try(self, mock_input):
170-
self.game.console.get_integer_input.side_effect = [0, 1]
171-
172-
expected: int = 1
173-
expected_call_count: int = 2
174-
actual = self.game.get_row()
175-
actual_call_count: int = self.game.console.get_integer_input.call_count
176-
177-
self.assertEqual(expected, actual)
178-
self.assertEqual(expected_call_count, actual_call_count)
179-
180-
@patch(f"{IOCONSOLE_PATH}.get_integer_input", side_effect=[0, 5, 6, 7, 2])
181-
def test_get_row_fifth_try(self, mock_input):
182-
183-
expected: int = 2
184-
expected_call_count: int = 5
185-
actual = self.game.get_row()
186-
actual_call_count: int = self.game.console.get_integer_input.call_count
187-
188-
self.assertEqual(expected, actual)
189-
self.assertEqual(expected_call_count, actual_call_count)
190-
191168
@patch(f"{IOCONSOLE_PATH}.get_integer_input", return_value=1)
192169
def test_get_col_first_try(self, mock_input):
193170

0 commit comments

Comments
 (0)