-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
38 lines (29 loc) · 1.04 KB
/
Copy pathtest.py
File metadata and controls
38 lines (29 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import unittest
from chess import play, PlayerByManual, Checkmate, Camp, Chess, Job, Square, Movement, validate_movement, RuleBroken, \
PCastle
class Test(unittest.TestCase):
def test_checkmate(self):
self.assertEqual(
Checkmate(winner=Camp.A),
play(*PlayerByManual.pair_by_manual_text('''
e2-e4 # A
e7-e5 # B
f1-c4 # A
f8-c5 # B
d1-f3 # A
b8-a6 # B
f3xf7 # A
'''))
)
def test_move_out_of_board(self):
chess = Chess.setup(initial=[
[Camp.A, Job.CASTLE, Square.by_name('a1')],
[Camp.A, Job.KING, Square.by_name('a2')],
[Camp.B, Job.KING, Square.by_name('h7')],
])
chess.turn = Camp.A
mv = Movement(piece=PCastle(camp=Camp.A), frm=Square.by_name('a1'), to=Square.by_name('a0'))
with self.assertRaises(RuleBroken):
validate_movement(chess, mv)
if __name__ == '__main__':
unittest.main()