summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_os.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-12-15 12:06:02 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-12-15 12:06:02 (GMT)
commit65ee4674e290ba893509f51f192dd1c9aa3a0422 (patch)
treec1e960162df4444ff18a2ad3aff11d713ef9ea12 /Lib/test/test_os.py
parent0e32ea1089059a15b04a40c43bfe671e38ae16e7 (diff)
parentbad1257c96943dcb39584a41e1a178542479df97 (diff)
downloadcpython-65ee4674e290ba893509f51f192dd1c9aa3a0422.zip
cpython-65ee4674e290ba893509f51f192dd1c9aa3a0422.tar.gz
cpython-65ee4674e290ba893509f51f192dd1c9aa3a0422.tar.bz2
Issue #22777: Test pickling with all protocols.
Diffstat (limited to 'Lib/test/test_os.py')
-rw-r--r--Lib/test/test_os.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 6281596..a047048 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -293,10 +293,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):
@@ -352,10 +355,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