diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-12-15 12:03:42 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-12-15 12:03:42 (GMT) |
commit | bad1257c96943dcb39584a41e1a178542479df97 (patch) | |
tree | dbb4594291c7df3660da701eb062bec35446bcba /Lib/test/test_os.py | |
parent | 79b81738ef052e9406adb8e98f0d292928053c01 (diff) | |
download | cpython-bad1257c96943dcb39584a41e1a178542479df97.zip cpython-bad1257c96943dcb39584a41e1a178542479df97.tar.gz cpython-bad1257c96943dcb39584a41e1a178542479df97.tar.bz2 |
Issue #22777: Test pickling with all protocols.
Diffstat (limited to 'Lib/test/test_os.py')
-rw-r--r-- | Lib/test/test_os.py | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index e129bef..ce6bd91 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -265,10 +265,13 @@ class StatAttributeTests(unittest.TestCase): def test_stat_result_pickle(self): result = os.stat(self.fname) - p = pickle.dumps(result) - self.assertIn(b'\x03cos\nstat_result\n', p) - unpickled = pickle.loads(p) - self.assertEqual(result, unpickled) + for proto in range(pickle.HIGHEST_PROTOCOL + 1): + p = pickle.dumps(result, proto) + self.assertIn(b'stat_result', p) + if proto < 4: + self.assertIn(b'cos\nstat_result\n', p) + unpickled = pickle.loads(p) + self.assertEqual(result, unpickled) @unittest.skipUnless(hasattr(os, 'statvfs'), 'test needs os.statvfs()') def test_statvfs_attributes(self): @@ -324,10 +327,13 @@ class StatAttributeTests(unittest.TestCase): if e.errno == errno.ENOSYS: self.skipTest('os.statvfs() failed with ENOSYS') - p = pickle.dumps(result) - self.assertIn(b'\x03cos\nstatvfs_result\n', p) - unpickled = pickle.loads(p) - self.assertEqual(result, unpickled) + for proto in range(pickle.HIGHEST_PROTOCOL + 1): + p = pickle.dumps(result, proto) + self.assertIn(b'statvfs_result', p) + if proto < 4: + self.assertIn(b'cos\nstatvfs_result\n', p) + unpickled = pickle.loads(p) + self.assertEqual(result, unpickled) def test_utime_dir(self): delta = 1000000 |