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