def test__expand(self): a = NestedDict({"k1": {"k2": {"k3": "v"}}}) b = a._expand(a.collapse()) self.assertEqual(b, a.get())
def test_get__path_arg__returns_value(self): a = NestedDict({"k1": {"k2": {"k3": "v"}}}) self.assertEqual(a.get(("k1", "k2")), {"k3": "v"})
def test_get__string_arg__raises_ValueError(self): a = NestedDict({"k1": {"k2": "v"}}) with self.assertRaises(TypeError): a.get(("k1", "k2", "k3"))
def test_get__string_arg__raises_KeyError(self): a = NestedDict() with self.assertRaises(KeyError): a.get("k")
def test_get__string_arg_missing_key__returns_default_value(self): a = NestedDict() self.assertEqual(a.get("k", "foo"), "foo")
def test_get__string_arg__returns_value(self): a = NestedDict({"k": "v"}) self.assertEqual(a.get("k"), "v")