From 33f4639bbf2f526f6a0dade6d351cb91f129cffd Mon Sep 17 00:00:00 2001 From: FlyingSamson Date: Sun, 22 May 2022 14:51:16 +0200 Subject: [PATCH] Add tests for functions taking svg objects as string --- test/test_svg2paths.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/test/test_svg2paths.py b/test/test_svg2paths.py index b5cf5b4..06220bb 100644 --- a/test/test_svg2paths.py +++ b/test/test_svg2paths.py @@ -74,7 +74,7 @@ class TestSVG2Paths(unittest.TestCase): self.assertEqual(len(paths), 2) def test_from_stringio(self): - """ Test reading svg object contained in an StringIO object """ + """ Test reading svg object contained in a StringIO object """ with open(join(dirname(__file__), 'polygons.svg'), 'r') as file: # read entire file into string file_content: str = file.read() @@ -88,3 +88,23 @@ class TestSVG2Paths(unittest.TestCase): paths, _ = svg2paths(file_as_stringio) self.assertEqual(len(paths), 2) + + def test_from_string_without_svg_attrs(self): + """ Test reading svg object contained in a string without svg attributes""" + with open(join(dirname(__file__), 'polygons.svg'), 'r') as file: + # read entire file into string + file_content: str = file.read() + + paths, _ = svg_string2paths(file_content) + + self.assertEqual(len(paths), 2) + + def test_from_string_with_svg_attrs(self): + """ Test reading svg object contained in a string with svg attributes""" + with open(join(dirname(__file__), 'polygons.svg'), 'r') as file: + # read entire file into string + file_content: str = file.read() + + paths, _, _ = svg_string2paths2(file_content) + + self.assertEqual(len(paths), 2)