summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_import.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-01-25 00:35:26 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-01-25 00:35:26 (GMT)
commit05f29b7a3aabc89000cce21d7bfec368f9ba5a26 (patch)
treefc0450b4e5c4bbfaf6076a291b6f1e126b0ed77f /Lib/test/test_import.py
parent2be60afb7e0753c1bd5c297960cf8686a1ec7e1e (diff)
downloadcpython-05f29b7a3aabc89000cce21d7bfec368f9ba5a26.zip
cpython-05f29b7a3aabc89000cce21d7bfec368f9ba5a26.tar.gz
cpython-05f29b7a3aabc89000cce21d7bfec368f9ba5a26.tar.bz2
Make test work under 32-bit systems, and when invoked through Lib/test/regrtest.py
(rather than `-m test.regrtest`)
Diffstat (limited to 'Lib/test/test_import.py')
-rw-r--r--Lib/test/test_import.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py
index 33277d7..95b90b8 100644
--- a/Lib/test/test_import.py
+++ b/Lib/test/test_import.py
@@ -313,14 +313,22 @@ 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")
+ __import__(TESTFN)
+ # The pyc file was created.
+ os.stat(compiled)
+ finally:
+ del sys.path[0]
+ remove_files(TESTFN)
class PycRewritingTests(unittest.TestCase):