M scfg/__init__.py +1 -2
@@ 23,8 23,7 @@ class Directive:
def __init__(self, name, params, children=None):
self.name = name
self.params = params
- if children is not None:
- self.children = children
+ self.children = children or []
def __str__(self):
return f"{self.name}: {self.params}"
M tests.py +9 -0
@@ 26,6 26,15 @@ class SCFGTest(unittest.TestCase):
train.get_all("model")[1].get("weight").params[0], "540t"
)
+ def test_access_missing(self):
+ train = self.config.get("train")
+ self.assertEqual(
+ train.get("missing"), None
+ )
+ self.assertEqual(
+ train.get_all("model")[0].get("lines-served").get("missing"), None
+ )
+
if __name__ == "__main__":
unittest.main()