diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-01-25 02:01:34 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-01-25 02:01:34 (GMT) |
commit | 157c1263a2d0563ad9929ae13a28838d5d7e5cad (patch) | |
tree | 60c44dfd0b78f30a2485a40a36e0494fe9ffcf69 /Lib/test/test_import.py | |
parent | abaf89b2be32db1deae32cbdf0645a4be65c6297 (diff) | |
parent | dd21f68963c2b17324b6018dbbf1b32b6e88f2c2 (diff) | |
download | cpython-157c1263a2d0563ad9929ae13a28838d5d7e5cad.zip cpython-157c1263a2d0563ad9929ae13a28838d5d7e5cad.tar.gz cpython-157c1263a2d0563ad9929ae13a28838d5d7e5cad.tar.bz2 |
Port remaining test fixes, and fix test_importlib too.
Diffstat (limited to 'Lib/test/test_import.py')
-rw-r--r-- | Lib/test/test_import.py | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py index 70787a4..d121ba3 100644 --- a/Lib/test/test_import.py +++ b/Lib/test/test_import.py @@ -11,6 +11,7 @@ import stat import sys import unittest import textwrap +import errno from test.support import ( EnvironmentVarGuard, TESTFN, check_warnings, forget, is_jython, @@ -309,14 +310,26 @@ class ImportTests(unittest.TestCase): def test_timestamp_overflow(self): # A modification timestamp larger than 2**32 should not be a problem # when importing a module (issue #11235). - source = TESTFN + ".py" - compiled = imp.cache_from_source(source) - with open(source, 'w') as f: - pass - os.utime(source, (2 ** 33, 2 ** 33)) - __import__(TESTFN) - # The pyc file was created. - os.stat(compiled) + sys.path.insert(0, os.curdir) + try: + source = TESTFN + ".py" + compiled = imp.cache_from_source(source) + with open(source, 'w') as f: + pass + try: + os.utime(source, (2 ** 33, 2 ** 33)) + except OverflowError: + self.skipTest("cannot set modification time to large integer") + except OSError as e: + if e.errno != getattr(errno, 'EOVERFLOW', None): + raise + self.skipTest("cannot set modification time to large integer ({})".format(e)) + __import__(TESTFN) + # The pyc file was created. + os.stat(compiled) + finally: + del sys.path[0] + remove_files(TESTFN) class PycRewritingTests(unittest.TestCase): |