From 988d2ccfbd78ef26c8652d0e92bdbb8cc186d548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20K=C3=A1cha?= <ph@cesnet.cz> Date: Tue, 31 Oct 2017 15:33:07 +0100 Subject: [PATCH] OpenTypedDict now clears its data before validation, fixed unittest --- test_typedcols.py | 8 +++++--- typedcols.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/test_typedcols.py b/test_typedcols.py index 6e0ab5c..53c0ec5 100755 --- a/test_typedcols.py +++ b/test_typedcols.py @@ -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) diff --git a/typedcols.py b/typedcols.py index 427fb56..5b6bea2 100644 --- a/typedcols.py +++ b/typedcols.py @@ -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 -- GitLab