diff options
author | Brett Cannon <brett@python.org> | 2013-05-03 10:37:08 -0400 |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2013-05-03 10:37:08 -0400 |
commit | 9d0f772c5115217d55aef76fae33f483f2a98032 (patch) | |
tree | a9cf061e4964455f440db0d4a074ff167fef5837 /Lib/test/test_imp.py | |
parent | b98dcc1f5307789c3c42af701f81147e240b90ff (diff) | |
download | cpython-9d0f772c5115217d55aef76fae33f483f2a98032.tar.gz cpython-9d0f772c5115217d55aef76fae33f483f2a98032.zip |
Issue #15902: Fix imp.load_module() to accept None as a file when
trying to load an extension module.
While at it, also add a proper unittest.skipIf() guard to another test
involving imp.load_dynamic().
Diffstat (limited to 'Lib/test/test_imp.py')
-rw-r--r-- | Lib/test/test_imp.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_imp.py b/Lib/test/test_imp.py index 72ae145f682..2b2bbd3c162 100644 --- a/Lib/test/test_imp.py +++ b/Lib/test/test_imp.py @@ -208,6 +208,8 @@ class ImportTests(unittest.TestCase): self.assertIsNot(orig_getenv, new_os.getenv) @support.cpython_only + @unittest.skipIf(not hasattr(imp, 'load_dynamic'), + 'imp.load_dynamic() required') def test_issue15828_load_extensions(self): # Issue 15828 picked up that the adapter between the old imp API # and importlib couldn't handle C extensions @@ -230,6 +232,19 @@ class ImportTests(unittest.TestCase): self.assertIn(path, err.exception.path) self.assertEqual(name, err.exception.name) + @support.cpython_only + @unittest.skipIf(not hasattr(imp, 'load_dynamic'), + 'imp.load_dynamic() required') + def test_load_module_extension_file_is_None(self): + # When loading an extension module and the file is None, open one + # on the behalf of imp.load_dynamic(). + # Issue #15902 + name = '_heapq' + found = imp.find_module(name) + assert found[2][2] == imp.C_EXTENSION + found[0].close() + imp.load_module(name, None, *found[1:]) + class ReloadTests(unittest.TestCase): |