[Python-checkins] cpython (merge 3.2 -> default): Port remaining test fixes, and fix test_importlib too.
antoine.pitrou
python-checkins at python.org
Wed Jan 25 03:03:44 CET 2012
http://hg.python.org/cpython/rev/454d1c52f3e0
changeset: 74604:454d1c52f3e0
parent: 74597:cb13d8cff050
parent: 74603:37ac757a9145
user: Antoine Pitrou <solipsis at pitrou.net>
date: Wed Jan 25 03:01:34 2012 +0100
summary:
Port remaining test fixes, and fix test_importlib too.
files:
Lib/importlib/test/source/test_file_loader.py | 10 +++-
Lib/test/test_import.py | 29 +++++++--
2 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/Lib/importlib/test/source/test_file_loader.py b/Lib/importlib/test/source/test_file_loader.py
--- a/Lib/importlib/test/source/test_file_loader.py
+++ b/Lib/importlib/test/source/test_file_loader.py
@@ -4,6 +4,7 @@
from .. import util
from . import util as source_util
+import errno
import imp
import marshal
import os
@@ -131,7 +132,14 @@
compiled = imp.cache_from_source(source)
with open(source, 'w') as f:
f.write("x = 5")
- os.utime(source, (2 ** 33, 2 ** 33))
+ 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))
loader = _bootstrap._SourceFileLoader('_temp', mapping['_temp'])
mod = loader.load_module('_temp')
# Sanity checks.
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
@@ -11,6 +11,7 @@
import sys
import unittest
import textwrap
+import errno
from test.support import (
EnvironmentVarGuard, TESTFN, check_warnings, forget, is_jython,
@@ -309,14 +310,26 @@
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):
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list