Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
b5f03c67
Commit
b5f03c67
authored
Mar 04, 2009
by
Brett Cannon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a test for importlib.import_module.
parent
4fa88fa0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletion
+10
-1
Lib/importlib/test/test_api.py
Lib/importlib/test/test_api.py
+10
-1
No files found.
Lib/importlib/test/test_api.py
View file @
b5f03c67
...
...
@@ -26,7 +26,7 @@ class ImportModuleTests(unittest.TestCase):
module
=
importlib
.
import_module
(
name
)
self
.
assertEqual
(
module
.
__name__
,
name
)
def
test_relative_package_import
(
self
):
def
test_
shallow_
relative_package_import
(
self
):
# Test importing a module from a package through a relatve import.
pkg_name
=
'pkg'
pkg_long_name
=
'{0}.__init__'
.
format
(
pkg_name
)
...
...
@@ -39,6 +39,15 @@ class ImportModuleTests(unittest.TestCase):
module
=
importlib
.
import_module
(
relative_name
,
pkg_name
)
self
.
assertEqual
(
module
.
__name__
,
absolute_name
)
def
test_deep_relative_package_import
(
self
):
modules
=
[
'a.__init__'
,
'a.b.__init__'
,
'a.c'
]
with
util
.
mock_modules
(
*
modules
)
as
mock
:
with
util
.
import_state
(
meta_path
=
[
mock
]):
importlib
.
import_module
(
'a'
)
importlib
.
import_module
(
'a.b'
)
module
=
importlib
.
import_module
(
'..c'
,
'a.b'
)
self
.
assertEqual
(
module
.
__name__
,
'a.c'
)
def
test_absolute_import_with_package
(
self
):
# Test importing a module from a package with an absolute name with
# the 'package' argument given.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment