Skip to content
Snippets Groups Projects
Commit 988d2ccf authored by Pavel Kácha's avatar Pavel Kácha
Browse files

OpenTypedDict now clears its data before validation, fixed unittest

parent 3b85355d
Branches
No related tags found
No related merge requests found
...@@ -43,7 +43,8 @@ person_init_data = { ...@@ -43,7 +43,8 @@ person_init_data = {
"street": "Vrchlikova", "street": "Vrchlikova",
"num": 12.3, "num": 12.3,
"city": "Kocourkov", "city": "Kocourkov",
"unknown": "blah" "unknown": "blah",
"state": "Bananistan"
}, },
"discard1": "junk", "discard1": "junk",
"discard2": "garbage", "discard2": "garbage",
...@@ -78,7 +79,8 @@ class TestTypedDict(unittest.TestCase): ...@@ -78,7 +79,8 @@ class TestTypedDict(unittest.TestCase):
"street": "Vrchlikova", "street": "Vrchlikova",
"num": 12, "num": 12,
"city": "Kocourkov", "city": "Kocourkov",
"unknown": "blah"}}) "unknown": "blah",
"state": "Bananistan"}})
def testSetGetKnownOk(self): def testSetGetKnownOk(self):
self.person["address"]["city"] = "Brno" self.person["address"]["city"] = "Brno"
...@@ -128,7 +130,7 @@ class TestTypedDict(unittest.TestCase): ...@@ -128,7 +130,7 @@ class TestTypedDict(unittest.TestCase):
it = self.person.items() it = self.person.items()
res = sorted([v for v in it]) res = sorted([v for v in it])
self.assertEqual(res, [ self.assertEqual(res, [
("address", {"city": "Kocourkov", "street": "Vrchlikova", "num": 12, "unknown": "blah"}), ("address", {"city": "Kocourkov", "state": "Bananistan", "street": "Vrchlikova", "num": 12, "unknown": "blah"}),
("age", 34), ("age", 34),
("name", "_Default_Value_"), ("name", "_Default_Value_"),
("note", None) ("note", None)
......
...@@ -275,7 +275,7 @@ class OpenTypedDict(TypedDictBase): ...@@ -275,7 +275,7 @@ class OpenTypedDict(TypedDictBase):
definitions. Note however that these classes are mutable, so definitions. Note however that these classes are mutable, so
assigning new values replaces old ones. assigning new values replaces old ones.
""" """
self.update(data) super(OpenTypedDict, self).__init__(data)
return self return self
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment