Skip to content

Commit b133b5f

Browse files
committed
Add PGN leading whitespace header test
1 parent 1aa08dc commit b133b5f

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

test.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,6 +2233,24 @@ def test_read_game(self):
22332233
self.assertEqual(sixth_game.headers["White"], "Deep Blue (Computer)")
22342234
self.assertEqual(sixth_game.headers["Result"], "1-0")
22352235

2236+
def test_read_game_with_leading_whitespace_before_header(self):
2237+
pgn = io.StringIO(
2238+
' [Event "TCEC Season 27 - Entrance League"]\n'
2239+
'[Site "https://tcec-chess.com"]\n'
2240+
'[White "Patricia 3.1_dev_ca7ef0a3"]\n'
2241+
'[Black "Weiss 2.1-dev11"]\n'
2242+
'[Result "*"]\n'
2243+
"\n"
2244+
"1. d4 *"
2245+
)
2246+
2247+
game = chess.pgn.read_game(pgn)
2248+
2249+
self.assertEqual(game.headers["Event"], "TCEC Season 27 - Entrance League")
2250+
self.assertEqual(game.headers["White"], "Patricia 3.1_dev_ca7ef0a3")
2251+
self.assertEqual(game.next().move, chess.Move.from_uci("d2d4"))
2252+
self.assertEqual(game.errors, [])
2253+
22362254
def test_read_game_with_multicomment_move(self):
22372255
pgn = io.StringIO("1. e4 {A common opening} 1... e5 {A common response} {An uncommon comment}")
22382256
game = chess.pgn.read_game(pgn)

0 commit comments

Comments
 (0)