summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAndrew Svetlov <andrew.svetlov@gmail.com>2012-12-14 15:04:59 (GMT)
committerAndrew Svetlov <andrew.svetlov@gmail.com>2012-12-14 15:04:59 (GMT)
commit6b2cbeba58aeb0755bdefd02fb51a80ec66d6144 (patch)
tree2634f036965fc3ebf737ef3ce1b830437de9a04f /Lib
parentf76f0eea5c00ea20ac62d9a8437a19f23fd455c5 (diff)
downloadcpython-6b2cbeba58aeb0755bdefd02fb51a80ec66d6144.zip
cpython-6b2cbeba58aeb0755bdefd02fb51a80ec66d6144.tar.gz
cpython-6b2cbeba58aeb0755bdefd02fb51a80ec66d6144.tar.bz2
Issue #16421: allow to load multiple modules from the same shared object.
Patch by Václav Šmilauer.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_imp.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_imp.py b/Lib/test/test_imp.py
index 65c9f25..bf2141f 100644
--- a/Lib/test/test_imp.py
+++ b/Lib/test/test_imp.py
@@ -217,6 +217,20 @@ class ImportTests(unittest.TestCase):
mod = imp.load_module(example, *x)
self.assertEqual(mod.__name__, example)
+ def test_issue16421_multiple_modules_in_one_dll(self):
+ # Issue 16421: loading several modules from the same compiled file fails
+ m = '_testimportmultiple'
+ fileobj, pathname, description = imp.find_module(m)
+ fileobj.close()
+ mod0 = imp.load_dynamic(m, pathname)
+ mod1 = imp.load_dynamic('foo', pathname)
+ mod2 = imp.load_dynamic('bar', pathname)
+ self.assertEqual(mod0.__name__, m)
+ self.assertEqual(mod1.__name__, 'foo')
+ self.assertEqual(mod2.__name__, 'bar')
+ with self.assertRaises(ImportError):
+ imp.load_dynamic('nonexistent', pathname)
+
def test_load_dynamic_ImportError_path(self):
# Issue #1559549 added `name` and `path` attributes to ImportError
# in order to provide better detail. Issue #10854 implemented those