22
33from queen_attack import Queen
44
5-
65# Tests adapted from `problem-specifications//canonical-data.json` @ v2.3.0
76
8- class QueenAttackTest (unittest .TestCase ):
97
8+ class QueenAttackTest (unittest .TestCase ):
109 # Test creation of Queens with valid and invalid positions
11- def test_queen_valid_position (self ):
12- try :
13- Queen (2 , 2 )
14- except ValueError :
15- self .fail ("Unexpected Exception" )
10+ def test_queen_with_a_valid_position (self ):
11+ Queen (2 , 2 )
1612
17- def test_queen_negative_row (self ):
13+ def test_queen_must_have_positive_row (self ):
1814 with self .assertRaisesWithMessage (ValueError ):
1915 Queen (- 2 , 2 )
2016
21- def test_queen_invalid_row (self ):
17+ def test_queen_must_have_row_on_board (self ):
2218 with self .assertRaisesWithMessage (ValueError ):
2319 Queen (8 , 4 )
2420
25- def test_queen_negative_column (self ):
21+ def test_queen_must_have_positive_column (self ):
2622 with self .assertRaisesWithMessage (ValueError ):
2723 Queen (2 , - 2 )
2824
29- def test_queen_invalid_column (self ):
25+ def test_queen_must_have_column_on_board (self ):
3026 with self .assertRaisesWithMessage (ValueError ):
3127 Queen (4 , 8 )
3228
3329 # Test the ability of one queen to attack another
34- def test_attack_false (self ):
30+ def test_can_not_attack (self ):
3531 self .assertIs (Queen (2 , 4 ).can_attack (Queen (6 , 6 )), False )
3632
37- def test_attack_same_row (self ):
33+ def test_can_attack_on_same_row (self ):
3834 self .assertIs (Queen (2 , 4 ).can_attack (Queen (2 , 6 )), True )
3935
40- def test_attack_same_column (self ):
36+ def test_can_attack_on_same_column (self ):
4137 self .assertIs (Queen (4 , 5 ).can_attack (Queen (2 , 5 )), True )
4238
43- def test_attack_diagonal1 (self ):
39+ def test_can_attack_on_first_diagonal (self ):
4440 self .assertIs (Queen (2 , 2 ).can_attack (Queen (0 , 4 )), True )
4541
46- def test_attack_diagonal2 (self ):
42+ def test_can_attack_on_second_diagonal (self ):
4743 self .assertIs (Queen (2 , 2 ).can_attack (Queen (3 , 1 )), True )
4844
49- def test_attack_diagonal3 (self ):
45+ def test_can_attack_on_third_diagonal (self ):
5046 self .assertIs (Queen (2 , 2 ).can_attack (Queen (1 , 1 )), True )
5147
52- def test_attack_diagonal4 (self ):
48+ def test_can_attack_on_fourth_diagonal (self ):
5349 self .assertIs (Queen (1 , 7 ).can_attack (Queen (0 , 6 )), True )
5450
5551 # Track-specific tests
@@ -62,5 +58,5 @@ def assertRaisesWithMessage(self, exception):
6258 return self .assertRaisesRegex (exception , r".+" )
6359
6460
65- if __name__ == ' __main__' :
61+ if __name__ == " __main__" :
6662 unittest .main ()
0 commit comments