diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2013-02-17 01:20:32 (GMT) |
---|---|---|
committer | Eric Snow <ericsnowcurrently@gmail.com> | 2013-02-17 01:20:32 (GMT) |
commit | 9d05c8c0e0b0f3ebd19d7add842d2db8269f7d75 (patch) | |
tree | f9fbeb1d362995d5c6adce96ca1c38de57964013 /Lib | |
parent | dcbe46bc5bad217e934568cfe59e3e807501acc3 (diff) | |
download | cpython-9d05c8c0e0b0f3ebd19d7add842d2db8269f7d75.zip cpython-9d05c8c0e0b0f3ebd19d7add842d2db8269f7d75.tar.gz cpython-9d05c8c0e0b0f3ebd19d7add842d2db8269f7d75.tar.bz2 |
Issue #15022: Ensure all pickle protocols are supported.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_types.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py index de0aac2..ec10752 100644 --- a/Lib/test/test_types.py +++ b/Lib/test/test_types.py @@ -1159,10 +1159,15 @@ class SimpleNamespaceTests(unittest.TestCase): def test_pickle(self): ns = types.SimpleNamespace(breakfast="spam", lunch="spam") - ns_pickled = pickle.dumps(ns) - ns_roundtrip = pickle.loads(ns_pickled) - - self.assertEqual(ns, ns_roundtrip) + for protocol in range(pickle.HIGHEST_PROTOCOL + 1): + pname = "protocol {}".format(protocol) + try: + ns_pickled = pickle.dumps(ns, protocol) + except TypeError as e: + raise TypeError(pname) from e + ns_roundtrip = pickle.loads(ns_pickled) + + self.assertEqual(ns, ns_roundtrip, pname) def test_main(): |