diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-12-15 12:02:43 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-12-15 12:02:43 (GMT) |
commit | 655720e2758a15c85effb340ff65f4b93e7cc7a7 (patch) | |
tree | d582731bc3e14a86222093e806d2ec88b2640f8f /Lib/test/test_decimal.py | |
parent | c3741a067b3443cdac7739b21e0cd1bacf155b02 (diff) | |
download | cpython-655720e2758a15c85effb340ff65f4b93e7cc7a7.zip cpython-655720e2758a15c85effb340ff65f4b93e7cc7a7.tar.gz cpython-655720e2758a15c85effb340ff65f4b93e7cc7a7.tar.bz2 |
Issue #22777: Test pickling with all protocols.
Diffstat (limited to 'Lib/test/test_decimal.py')
-rw-r--r-- | Lib/test/test_decimal.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index 4dbe62d..de309ba 100644 --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -1664,9 +1664,10 @@ class DecimalPythonAPItests(unittest.TestCase): def test_pickle(self): d = Decimal('-3.141590000') - p = pickle.dumps(d) - e = pickle.loads(p) - self.assertEqual(d, e) + for proto in range(pickle.HIGHEST_PROTOCOL + 1): + p = pickle.dumps(d, proto) + e = pickle.loads(p) + self.assertEqual(d, e) def test_int(self): for x in range(-250, 250): @@ -1750,12 +1751,13 @@ class DecimalPythonAPItests(unittest.TestCase): class ContextAPItests(unittest.TestCase): def test_pickle(self): - c = Context() - e = pickle.loads(pickle.dumps(c)) - for k in vars(c): - v1 = vars(c)[k] - v2 = vars(e)[k] - self.assertEqual(v1, v2) + for proto in range(pickle.HIGHEST_PROTOCOL + 1): + c = Context() + e = pickle.loads(pickle.dumps(c, proto)) + for k in vars(c): + v1 = vars(c)[k] + v2 = vars(e)[k] + self.assertEqual(v1, v2) def test_equality_with_other_types(self): self.assertIn(Decimal(10), ['a', 1.0, Decimal(10), (1,2), {}]) |