diff --git a/svgpathtools/document.py b/svgpathtools/document.py index f88f5ba..1dd9077 100644 --- a/svgpathtools/document.py +++ b/svgpathtools/document.py @@ -289,7 +289,7 @@ class Document: # If given a list of strings (one or more), assume it represents # 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) elif not isinstance(group, Element): diff --git a/test/test_groups.py b/test/test_groups.py index 44b6cb9..aeb3393 100644 --- a/test/test_groups.py +++ b/test/test_groups.py @@ -235,4 +235,11 @@ class TestGroups(unittest.TestCase): path = parse_path(path_d) svg_path = doc.add_path(path, group=new_leaf) - self.assertEqual(path_d, svg_path.get('d')) \ No newline at end of file + 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'))