diff options
author | Christian Heimes <christian@cheimes.de> | 2013-10-11 23:27:08 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2013-10-11 23:27:08 (GMT) |
commit | 2582762b1b76a9bbe11f8ba5fc2a350157526050 (patch) | |
tree | 2842450f57aa729c32fdba59c98558f0ad324650 /Lib/test/test_os.py | |
parent | 1a5fb4e3c1d99a0abbb9f1e9dd6f9322102ee812 (diff) | |
download | cpython-2582762b1b76a9bbe11f8ba5fc2a350157526050.zip cpython-2582762b1b76a9bbe11f8ba5fc2a350157526050.tar.gz cpython-2582762b1b76a9bbe11f8ba5fc2a350157526050.tar.bz2 |
Issue #19209: Remove import of copyreg from the os module to speed up
interpreter startup. stat_result and statvfs_result are now hard-coded to
reside in the os module.
The patch is based on Victor Stinner's patch.
Diffstat (limited to 'Lib/test/test_os.py')
-rw-r--r-- | Lib/test/test_os.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index 39b0e80..ab44d01 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -26,6 +26,7 @@ import locale import codecs import decimal import fractions +import pickle try: import threading except ImportError: @@ -264,6 +265,13 @@ class StatAttributeTests(unittest.TestCase): warnings.simplefilter("ignore", DeprecationWarning) self.check_stat_attributes(fname) + 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) + def test_statvfs_attributes(self): if not hasattr(os, "statvfs"): return @@ -310,6 +318,20 @@ class StatAttributeTests(unittest.TestCase): except TypeError: pass + @unittest.skipUnless(hasattr(os, 'statvfs'), + "need os.statvfs()") + def test_statvfs_result_pickle(self): + try: + result = os.statvfs(self.fname) + except OSError as e: + # On AtheOS, glibc always returns ENOSYS + if e.errno == errno.ENOSYS: + return + p = pickle.dumps(result) + self.assertIn(b'\x03cos\nstatvfs_result\n', p) + unpickled = pickle.loads(p) + self.assertEqual(result, unpickled) + def test_utime_dir(self): delta = 1000000 st = os.stat(support.TESTFN) |