Make test work under 32-bit systems, and when invoked through Lib/test/regrtest.py

(rather than `-m test.regrtest`)
This commit is contained in:
Antoine Pitrou 2012-01-25 01:35:26 +01:00
parent a1f948bdec
commit e3668e9842
1 changed files with 16 additions and 9 deletions

View File

@ -280,15 +280,22 @@ class ImportTests(unittest.TestCase):
def test_timestamp_overflow(self): def test_timestamp_overflow(self):
# A modification timestamp larger than 2**32 should not be a problem # A modification timestamp larger than 2**32 should not be a problem
# when importing a module (issue #11235). # when importing a module (issue #11235).
sys.path.insert(0, os.curdir)
try:
source = TESTFN + ".py" source = TESTFN + ".py"
self.addCleanup(remove_files, TESTFN)
compiled = source + ('c' if __debug__ else 'o') compiled = source + ('c' if __debug__ else 'o')
with open(source, 'w') as f: with open(source, 'w') as f:
pass pass
try:
os.utime(source, (2 ** 33, 2 ** 33)) os.utime(source, (2 ** 33, 2 ** 33))
except OverflowError:
self.skipTest("cannot set modification time to large integer")
__import__(TESTFN) __import__(TESTFN)
# The pyc file was created. # The pyc file was created.
os.stat(compiled) os.stat(compiled)
finally:
del sys.path[0]
remove_files(TESTFN)
class PycRewritingTests(unittest.TestCase): class PycRewritingTests(unittest.TestCase):