Skip to content

Commit 00a579a

Browse files
committed
test svg using xpath searches
1 parent c7ccfc3 commit 00a579a

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

test.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3734,12 +3734,18 @@ def test_svg_board(self):
37343734

37353735
def test_svg_arrows(self):
37363736
svg = chess.svg.board(arrows=[(chess.A1, chess.A1)])
3737-
self.assertIn("<circle", svg)
3738-
self.assertNotIn("<line", svg)
3737+
parsed_svg = chess.svg.ET.fromstring(svg)
3738+
ns = {"svg": "http://www.w3.org/2000/svg"}
3739+
3740+
self.assertIsNotNone(parsed_svg.find("./svg:circle", ns))
3741+
self.assertIsNone(parsed_svg.find("./*[@class='arrow']", ns))
37393742

37403743
svg = chess.svg.board(arrows=[chess.svg.Arrow(chess.A1, chess.H8)])
3741-
self.assertNotIn("<circle", svg)
3742-
self.assertIn("<line", svg)
3744+
parsed_svg = chess.svg.ET.fromstring(svg)
3745+
3746+
self.assertIsNone(parsed_svg.find("./svg:circle", ns))
3747+
3748+
self.assertIsNotNone(parsed_svg.find("./svg:polygon[@class='arrow']", ns))
37433749

37443750
def test_svg_piece(self):
37453751
svg = chess.svg.piece(chess.Piece.from_symbol("K"))

0 commit comments

Comments
 (0)