Exemplo n.º 1
0
 def test_push__create_False__raises_TypeError(self):
     a = NestedDict({"k": "v"})
     with self.assertRaises(AttributeError):
         a.push("k", "v", create=False)
Exemplo n.º 2
0
 def test_push__create_False__raises_KeyError(self):
     a = NestedDict()
     with self.assertRaises(KeyError):
         a.push("k", "v", create=False)
Exemplo n.º 3
0
 def test_push__create_True__creates_list(self):
     a = NestedDict()
     a.push("k", "v")
     self.assertEqual(a, {"k": ["v"]})
Exemplo n.º 4
0
 def test_push__path_arg(self):
     a = NestedDict({"k1": {"k2": {"k3": []}}})
     a.push(("k1", "k2", "k3"), "v")
     self.assertEqual(a, {"k1": {"k2": {"k3": ["v"]}}})
Exemplo n.º 5
0
 def test_push__string_arg__convert_existing_value(self):
     a = NestedDict({"k": "v"})
     a.push("k", "v")
     self.assertEqual(a, {"k": ["v", "v"]})
Exemplo n.º 6
0
 def test_push__string_arg(self):
     a = NestedDict({"k": []})
     a.push("k", "v")
     self.assertEqual(a, {"k": ["v"]})