Fix Document.add_path for empty groups (#170)
parent
c84c897bf2
commit
19df25b99b
|
@ -289,7 +289,7 @@ class Document:
|
||||||
|
|
||||||
# If given a list of strings (one or more), assume it represents
|
# If given a list of strings (one or more), assume it represents
|
||||||
# a sequence of nested group names
|
# a sequence of nested group names
|
||||||
elif all(isinstance(elem, str) for elem in group):
|
elif len(group) > 0 and all(isinstance(elem, str) for elem in group):
|
||||||
group = self.get_or_add_group(group)
|
group = self.get_or_add_group(group)
|
||||||
|
|
||||||
elif not isinstance(group, Element):
|
elif not isinstance(group, Element):
|
||||||
|
|
|
@ -236,3 +236,10 @@ class TestGroups(unittest.TestCase):
|
||||||
path = parse_path(path_d)
|
path = parse_path(path_d)
|
||||||
svg_path = doc.add_path(path, group=new_leaf)
|
svg_path = doc.add_path(path, group=new_leaf)
|
||||||
self.assertEqual(path_d, svg_path.get('d'))
|
self.assertEqual(path_d, svg_path.get('d'))
|
||||||
|
|
||||||
|
# Test that paths are added to the correct group
|
||||||
|
new_sibling = doc.get_or_add_group(
|
||||||
|
['base_group', 'new_parent', 'new_sibling'])
|
||||||
|
doc.add_path(path, group=new_sibling)
|
||||||
|
self.assertEqual(len(new_sibling), 1)
|
||||||
|
self.assertEqual(path_d, new_sibling[0].get('d'))
|
||||||
|
|
Loading…
Reference in New Issue