diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2009-04-11 14:30:59 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2009-04-11 14:30:59 (GMT) |
commit | fce769e73d05ec2e879a389320412f14ddb733ea (patch) | |
tree | ac3215914c4b036ece271ba4ede0189f68427924 /Lib/test/test_warnings.py | |
parent | 2d87e42921c3dbf0833ddc51d5690a4032c19b6d (diff) | |
download | cpython-fce769e73d05ec2e879a389320412f14ddb733ea.zip cpython-fce769e73d05ec2e879a389320412f14ddb733ea.tar.gz cpython-fce769e73d05ec2e879a389320412f14ddb733ea.tar.bz2 |
Merged revisions 71465 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r71465 | nick.coghlan | 2009-04-11 23:31:31 +1000 (Sat, 11 Apr 2009) | 1 line
Issue 5354: Provide a standardised testing mechanism for doing fresh imports of modules, including the ability to block extension modules in order to test the pure Python fallbacks
........
Diffstat (limited to 'Lib/test/test_warnings.py')
-rw-r--r-- | Lib/test/test_warnings.py | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py index d04c3dd..1f377ad 100644 --- a/Lib/test/test_warnings.py +++ b/Lib/test/test_warnings.py @@ -10,18 +10,14 @@ from test import warning_tests import warnings as original_warnings -sys.modules['_warnings'] = 0 -del sys.modules['warnings'] - -import warnings as py_warnings - +py_warnings = support.import_fresh_module('warnings', ['_warnings']) +# XXX (ncoghlan 20090412): +# Something in Py3k doesn't like sharing the same instance of +# _warnings between original_warnings and c_warnings +# Will leave issue 5354 open until I understand why 3.x breaks +# without the next line, while 2.x doesn't care del sys.modules['_warnings'] -del sys.modules['warnings'] - -import warnings as c_warnings - -sys.modules['warnings'] = original_warnings - +c_warnings = support.import_fresh_module('warnings') @contextmanager def warnings_state(module): @@ -351,9 +347,21 @@ class WarnTests(unittest.TestCase): class CWarnTests(BaseTest, WarnTests): module = c_warnings + # As an early adopter, we sanity check the + # test.support.import_fresh_module utility function + def test_accelerated(self): + self.assertFalse(original_warnings is self.module) + self.assertFalse(hasattr(self.module.warn, '__code__')) + class PyWarnTests(BaseTest, WarnTests): module = py_warnings + # As an early adopter, we sanity check the + # test.support.import_fresh_module utility function + def test_pure_python(self): + self.assertFalse(original_warnings is self.module) + self.assertTrue(hasattr(self.module.warn, '__code__')) + class WCmdLineTests(unittest.TestCase): |