# parent is further down in hierarchy -> new level
(state, children, new_parent) = \
parse_cnf_children (state, new_parent)
+ cnf_line["children"] = children
if state is None:
break
- cnf_line["children"] = children
current = get(state)
new_parent = get_parent(current)
if new_parent is None:
self.assertEqual(str(cnf_input).splitlines(), expected_input.splitlines())
+ def test_correct_parsing_of_nested_cnf_from_string(self):
+ """Test that grandchildren cnfvars aren't disregarded when no other child cnfvar follows them."""
+ input = dedent("""\
+ 1 FIREWALL_NETGROUP,99: "QA host IP"
+ 2 (1) FIREWALL_NETGROUP_NETWORK,0: ""
+ 3 (2) FIREWALL_NETGROUP_NETWORK_IP,0: "192.168.1.254"
+ 4 (2) FIREWALL_NETGROUP_NETWORK_NETMASK,0: "255.255.255.255"
+ """)
+
+ cnf = CnfList.from_cnf_string(input)
+
+ self.assertEqual(str(cnf).splitlines(), input.splitlines())
+
def test_deleting_cnfvars(self):
"""Test that we can delete top-level cnfvars."""
# To avoid creating long dummy objects, we can convert our test file