[Python-checkins] cpython (2.7): Make test work under 32-bit systems, and when invoked through

antoine.pitrou python-checkins at python.org
Wed Jan 25 01:37:40 CET 2012


http://hg.python.org/cpython/rev/5f7ad3c26677
changeset:   74600:5f7ad3c26677
branch:      2.7
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Wed Jan 25 01:35:26 2012 +0100
summary:
  Make test work under 32-bit systems, and when invoked through Lib/test/regrtest.py
(rather than `-m test.regrtest`)

files:
  Lib/test/test_import.py |  25 ++++++++++++++++---------
  1 files changed, 16 insertions(+), 9 deletions(-)


diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py
--- a/Lib/test/test_import.py
+++ b/Lib/test/test_import.py
@@ -280,15 +280,22 @@
     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"
-        self.addCleanup(remove_files, TESTFN)
-        compiled = source + ('c' if __debug__ else 'o')
-        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 = source + ('c' if __debug__ else 'o')
+            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):

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list