diff options
author | Yurii Karabas <1998uriyyo@gmail.com> | 2021-07-24 09:53:40 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-24 09:53:40 (GMT) |
commit | a22b05da87bdfb081d6aaecfce136ae8dbb8680c (patch) | |
tree | 394b1af5e7c8a58a9b99d0ef589e96e4b480e289 /Lib/test/test_typing.py | |
parent | 8072a1181dd64135f700b44372fbf7bf91e68072 (diff) | |
download | cpython-a22b05da87bdfb081d6aaecfce136ae8dbb8680c.zip cpython-a22b05da87bdfb081d6aaecfce136ae8dbb8680c.tar.gz cpython-a22b05da87bdfb081d6aaecfce136ae8dbb8680c.tar.bz2 |
bpo-44353: Improve tests covering typing.NewType pickling (GH-27302)
Diffstat (limited to 'Lib/test/test_typing.py')
-rw-r--r-- | Lib/test/test_typing.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 13ac395..85cb527 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -3755,16 +3755,17 @@ class NewTypeTests: def test_pickle(self): UserAge = self.module.NewType('UserAge', float) for proto in range(pickle.HIGHEST_PROTOCOL + 1): - pickled = pickle.dumps(UserId, proto) - loaded = pickle.loads(pickled) - self.assertIs(loaded, UserId) + with self.subTest(proto=proto): + pickled = pickle.dumps(UserId, proto) + loaded = pickle.loads(pickled) + self.assertIs(loaded, UserId) - pickled = pickle.dumps(self.UserName, proto) - loaded = pickle.loads(pickled) - self.assertIs(loaded, self.UserName) + pickled = pickle.dumps(self.UserName, proto) + loaded = pickle.loads(pickled) + self.assertIs(loaded, self.UserName) - with self.assertRaises(pickle.PicklingError): - pickle.dumps(UserAge, proto) + with self.assertRaises(pickle.PicklingError): + pickle.dumps(UserAge, proto) class NewTypePythonTests(NewTypeTests, BaseTestCase): |