Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 05f29b7

Browse files
committed
Make test work under 32-bit systems, and when invoked through Lib/test/regrtest.py
(rather than `-m test.regrtest`)
1 parent 2be60af commit 05f29b7

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

Lib/test/test_import.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -313,14 +313,22 @@ def __del__(self):
313313
def test_timestamp_overflow(self):
314314
# A modification timestamp larger than 2**32 should not be a problem
315315
# when importing a module (issue #11235).
316-
source = TESTFN + ".py"
317-
compiled = imp.cache_from_source(source)
318-
with open(source, 'w') as f:
319-
pass
320-
os.utime(source, (2 ** 33, 2 ** 33))
321-
__import__(TESTFN)
322-
# The pyc file was created.
323-
os.stat(compiled)
316+
sys.path.insert(0, os.curdir)
317+
try:
318+
source = TESTFN + ".py"
319+
compiled = imp.cache_from_source(source)
320+
with open(source, 'w') as f:
321+
pass
322+
try:
323+
os.utime(source, (2 ** 33, 2 ** 33))
324+
except OverflowError:
325+
self.skipTest("cannot set modification time to large integer")
326+
__import__(TESTFN)
327+
# The pyc file was created.
328+
os.stat(compiled)
329+
finally:
330+
del sys.path[0]
331+
remove_files(TESTFN)
324332

325333

326334
class PycRewritingTests(unittest.TestCase):

0 commit comments

Comments
 (0)