mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Handle importing pkg.mod by executing
__import__('mod', {'__packaging__': 'pkg', level=1) w/o properly (and thus not segfaulting).
This commit is contained in:
parent
59f9c3affc
commit
49f8d8b016
4 changed files with 276 additions and 253 deletions
|
@ -193,6 +193,15 @@ class RelativeImports(unittest.TestCase):
|
|||
self.assertEqual(module.__name__, '__runpy_pkg__.uncle.cousin')
|
||||
self.relative_import_test(create, globals_, callback)
|
||||
|
||||
def test_import_relative_import_no_fromlist(self):
|
||||
# Import a relative module w/ no fromlist.
|
||||
create = ['crash.__init__', 'crash.mod']
|
||||
globals_ = [{'__package__': 'crash', '__name__': 'crash'}]
|
||||
def callback(global_):
|
||||
import_util.import_('crash')
|
||||
mod = import_util.import_('mod', global_, {}, [], 1)
|
||||
self.assertEqual(mod.__name__, 'crash.mod')
|
||||
self.relative_import_test(create, globals_, callback)
|
||||
|
||||
|
||||
def test_main():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue