Esempio n. 1
0
 def popitem(self):
     c = Config(defaults={"foo": "bar"})
     assert c.popitem() == ("foo", "bar")
     assert c == {}
     c.nested = {"leafkey": "leafval"}
     assert c.nested.popitem() == ("leafkey", "leafval")
     assert c == {"nested": {}}
Esempio n. 2
0
 def clear(self):
     c = Config(defaults={"foo": "bar"})
     c.clear()
     assert c == {}
     c.nested = {"leafkey": "leafval"}
     c.nested.clear()
     assert c == {"nested": {}}
Esempio n. 3
0
 def delitem(self):
     "__delitem__"
     c = Config(defaults={"foo": "bar"})
     del c["foo"]
     assert c == {}
     c.nested = {"leafkey": "leafval"}
     del c.nested["leafkey"]
     assert c == {"nested": {}}
Esempio n. 4
0
 def delattr(self):
     "__delattr__"
     c = Config(defaults={"foo": "bar"})
     del c.foo
     assert c == {}
     c.nested = {"leafkey": "leafval"}
     del c.nested.leafkey
     assert c == {"nested": {}}
Esempio n. 5
0
 def pop(self):
     # Root
     c = Config(defaults={"foo": "bar"})
     assert c.pop("foo") == "bar"
     assert c == {}
     # With the default arg
     assert c.pop("wut", "fine then") == "fine then"
     # Leaf (different key to avoid AmbiguousMergeError)
     c.nested = {"leafkey": "leafval"}
     assert c.nested.pop("leafkey") == "leafval"
     assert c == {"nested": {}}