summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_types.py13
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():