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
faae3adb
Commit
faae3adb
authored
Jun 27, 2012
by
Eric V. Smith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed importlib tests to use assertIs, assertIsInstance, etc., instead of just assertTrue.
parent
8d37ffa5
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
58 additions
and
58 deletions
+58
-58
Lib/importlib/test/builtin/test_finder.py
Lib/importlib/test/builtin/test_finder.py
+2
-2
Lib/importlib/test/builtin/test_loader.py
Lib/importlib/test/builtin/test_loader.py
+5
-5
Lib/importlib/test/extension/test_finder.py
Lib/importlib/test/extension/test_finder.py
+1
-1
Lib/importlib/test/extension/test_loader.py
Lib/importlib/test/extension/test_loader.py
+4
-4
Lib/importlib/test/frozen/test_finder.py
Lib/importlib/test/frozen/test_finder.py
+1
-1
Lib/importlib/test/frozen/test_loader.py
Lib/importlib/test/frozen/test_loader.py
+3
-3
Lib/importlib/test/import_/test_caching.py
Lib/importlib/test/import_/test_caching.py
+2
-1
Lib/importlib/test/import_/test_meta_path.py
Lib/importlib/test/import_/test_meta_path.py
+2
-2
Lib/importlib/test/import_/test_packages.py
Lib/importlib/test/import_/test_packages.py
+11
-11
Lib/importlib/test/import_/test_path.py
Lib/importlib/test/import_/test_path.py
+6
-6
Lib/importlib/test/source/test_abc_loader.py
Lib/importlib/test/source/test_abc_loader.py
+10
-11
Lib/importlib/test/source/test_file_loader.py
Lib/importlib/test/source/test_file_loader.py
+6
-6
Lib/importlib/test/source/test_finder.py
Lib/importlib/test/source/test_finder.py
+1
-1
Lib/importlib/test/test_util.py
Lib/importlib/test/test_util.py
+4
-4
No files found.
Lib/importlib/test/builtin/test_finder.py
View file @
faae3adb
...
...
@@ -35,14 +35,14 @@ class FinderTests(abc.FinderTests):
def
test_failure
(
self
):
assert
'importlib'
not
in
sys
.
builtin_module_names
loader
=
machinery
.
BuiltinImporter
.
find_module
(
'importlib'
)
self
.
assert
True
(
loader
is
None
)
self
.
assert
Is
(
loader
,
None
)
def
test_ignore_path
(
self
):
# The value for 'path' should always trigger a failed import.
with
util
.
uncache
(
builtin_util
.
NAME
):
loader
=
machinery
.
BuiltinImporter
.
find_module
(
builtin_util
.
NAME
,
[
'pkg'
])
self
.
assert
True
(
loader
is
None
)
self
.
assert
Is
(
loader
,
None
)
...
...
Lib/importlib/test/builtin/test_loader.py
View file @
faae3adb
...
...
@@ -18,10 +18,10 @@ class LoaderTests(abc.LoaderTests):
def
verify
(
self
,
module
):
"""Verify that the module matches against what it should have."""
self
.
assert
True
(
isinstance
(
module
,
types
.
ModuleType
)
)
self
.
assert
IsInstance
(
module
,
types
.
ModuleType
)
for
attr
,
value
in
self
.
verification
.
items
():
self
.
assertEqual
(
getattr
(
module
,
attr
),
value
)
self
.
assert
True
(
module
.
__name__
in
sys
.
modules
)
self
.
assert
In
(
module
.
__name__
,
sys
.
modules
)
load_module
=
staticmethod
(
lambda
name
:
machinery
.
BuiltinImporter
.
load_module
(
name
))
...
...
@@ -49,7 +49,7 @@ class LoaderTests(abc.LoaderTests):
with
util
.
uncache
(
builtin_util
.
NAME
):
module1
=
self
.
load_module
(
builtin_util
.
NAME
)
module2
=
self
.
load_module
(
builtin_util
.
NAME
)
self
.
assert
True
(
module1
is
module2
)
self
.
assert
Is
(
module1
,
module2
)
def
test_unloadable
(
self
):
name
=
'dssdsdfff'
...
...
@@ -74,12 +74,12 @@ class InspectLoaderTests(unittest.TestCase):
def
test_get_code
(
self
):
# There is no code object.
result
=
machinery
.
BuiltinImporter
.
get_code
(
builtin_util
.
NAME
)
self
.
assert
True
(
result
is
None
)
self
.
assert
Is
(
result
,
None
)
def
test_get_source
(
self
):
# There is no source.
result
=
machinery
.
BuiltinImporter
.
get_source
(
builtin_util
.
NAME
)
self
.
assert
True
(
result
is
None
)
self
.
assert
Is
(
result
,
None
)
def
test_is_package
(
self
):
# Cannot be a package.
...
...
Lib/importlib/test/extension/test_finder.py
View file @
faae3adb
...
...
@@ -36,7 +36,7 @@ class FinderTests(abc.FinderTests):
pass
def
test_failure
(
self
):
self
.
assert
True
(
self
.
find_module
(
'asdfjkl;'
)
is
None
)
self
.
assert
Is
(
self
.
find_module
(
'asdfjkl;'
),
None
)
# XXX Raise an exception if someone tries to use the 'path' argument?
...
...
Lib/importlib/test/extension/test_loader.py
View file @
faae3adb
...
...
@@ -33,9 +33,9 @@ class LoaderTests(abc.LoaderTests):
(
'__file__'
,
ext_util
.
FILEPATH
),
(
'__package__'
,
''
)]:
self
.
assertEqual
(
getattr
(
module
,
attr
),
value
)
self
.
assert
True
(
ext_util
.
NAME
in
sys
.
modules
)
self
.
assert
True
(
isi
nstance
(
module
.
__loader__
,
machinery
.
ExtensionFileLoader
)
)
self
.
assert
In
(
ext_util
.
NAME
,
sys
.
modules
)
self
.
assert
IsI
nstance
(
module
.
__loader__
,
machinery
.
ExtensionFileLoader
)
def
test_package
(
self
):
# Extensions are not found in packages.
...
...
@@ -49,7 +49,7 @@ class LoaderTests(abc.LoaderTests):
with
util
.
uncache
(
ext_util
.
NAME
):
module1
=
self
.
load_module
(
ext_util
.
NAME
)
module2
=
self
.
load_module
(
ext_util
.
NAME
)
self
.
assert
True
(
module1
is
module2
)
self
.
assert
Is
(
module1
,
module2
)
def
test_state_after_failure
(
self
):
# No easy way to trigger a failure after a successful import.
...
...
Lib/importlib/test/frozen/test_finder.py
View file @
faae3adb
...
...
@@ -35,7 +35,7 @@ class FinderTests(abc.FinderTests):
def
test_failure
(
self
):
loader
=
self
.
find
(
'<not real>'
)
self
.
assert
True
(
loader
is
None
)
self
.
assert
Is
(
loader
,
None
)
def
test_main
():
...
...
Lib/importlib/test/frozen/test_loader.py
View file @
faae3adb
...
...
@@ -55,7 +55,7 @@ class LoaderTests(abc.LoaderTests):
with
util
.
uncache
(
'__hello__'
),
captured_stdout
()
as
stdout
:
module1
=
machinery
.
FrozenImporter
.
load_module
(
'__hello__'
)
module2
=
machinery
.
FrozenImporter
.
load_module
(
'__hello__'
)
self
.
assert
True
(
module1
is
module2
)
self
.
assert
Is
(
module1
,
module2
)
self
.
assertEqual
(
stdout
.
getvalue
(),
'Hello world!
\
n
Hello world!
\
n
'
)
...
...
@@ -93,7 +93,7 @@ class InspectLoaderTests(unittest.TestCase):
def
test_get_source
(
self
):
# Should always return None.
result
=
machinery
.
FrozenImporter
.
get_source
(
'__hello__'
)
self
.
assert
True
(
result
is
None
)
self
.
assert
Is
(
result
,
None
)
def
test_is_package
(
self
):
# Should be able to tell what is a package.
...
...
@@ -101,7 +101,7 @@ class InspectLoaderTests(unittest.TestCase):
(
'__phello__.spam'
,
False
))
for
name
,
is_package
in
test_for
:
result
=
machinery
.
FrozenImporter
.
is_package
(
name
)
self
.
assert
True
(
bool
(
result
)
==
is_package
)
self
.
assert
Equal
(
bool
(
result
),
is_package
)
def
test_failure
(
self
):
# Raise ImportError for modules that are not frozen.
...
...
Lib/importlib/test/import_/test_caching.py
View file @
faae3adb
...
...
@@ -65,7 +65,8 @@ class UseCache(unittest.TestCase):
with
util
.
import_state
(
meta_path
=
[
importer
]):
module
=
import_util
.
import_
(
'pkg.module'
)
self
.
assertTrue
(
hasattr
(
module
,
'module'
))
self
.
assertTrue
(
id
(
module
.
module
),
id
(
sys
.
modules
[
'pkg.module'
]))
self
.
assertEqual
(
id
(
module
.
module
),
id
(
sys
.
modules
[
'pkg.module'
]))
# See test_using_cache_after_loader() for reasoning.
@
import_util
.
importlib_only
...
...
Lib/importlib/test/import_/test_meta_path.py
View file @
faae3adb
...
...
@@ -82,7 +82,7 @@ class CallSignature(unittest.TestCase):
self
.
assertEqual
(
len
(
args
),
2
)
self
.
assertEqual
(
len
(
kwargs
),
0
)
self
.
assertEqual
(
args
[
0
],
mod_name
)
self
.
assert
True
(
args
[
1
]
is
None
)
self
.
assert
Is
(
args
[
1
],
None
)
def
test_with_path
(
self
):
# [path set]
...
...
@@ -102,7 +102,7 @@ class CallSignature(unittest.TestCase):
# Assuming all arguments are positional.
self
.
assertTrue
(
not
kwargs
)
self
.
assertEqual
(
args
[
0
],
mod_name
)
self
.
assert
True
(
args
[
1
]
is
path
)
self
.
assert
Is
(
args
[
1
],
path
)
...
...
Lib/importlib/test/import_/test_packages.py
View file @
faae3adb
...
...
@@ -14,7 +14,7 @@ class ParentModuleTests(unittest.TestCase):
with
util
.
mock_modules
(
'pkg.__init__'
,
'pkg.module'
)
as
mock
:
with
util
.
import_state
(
meta_path
=
[
mock
]):
module
=
import_util
.
import_
(
'pkg.module'
)
self
.
assert
True
(
'pkg'
in
sys
.
modules
)
self
.
assert
In
(
'pkg'
,
sys
.
modules
)
def
test_bad_parent
(
self
):
with
util
.
mock_modules
(
'pkg.module'
)
as
mock
:
...
...
@@ -33,12 +33,12 @@ class ParentModuleTests(unittest.TestCase):
with
util
.
import_state
(
meta_path
=
[
mock
]):
with
self
.
assertRaises
(
ZeroDivisionError
):
import_util
.
import_
(
'pkg'
)
self
.
assert
False
(
'pkg'
in
sys
.
modules
)
self
.
assert
True
(
'pkg.module'
in
sys
.
modules
)
self
.
assert
NotIn
(
'pkg'
,
sys
.
modules
)
self
.
assert
In
(
'pkg.module'
,
sys
.
modules
)
with
self
.
assertRaises
(
ZeroDivisionError
):
import_util
.
import_
(
'pkg.module'
)
self
.
assert
False
(
'pkg'
in
sys
.
modules
)
self
.
assert
True
(
'pkg.module'
in
sys
.
modules
)
self
.
assert
NotIn
(
'pkg'
,
sys
.
modules
)
self
.
assert
In
(
'pkg.module'
,
sys
.
modules
)
def
test_raising_parent_after_relative_importing_child
(
self
):
def
__init__
():
...
...
@@ -52,12 +52,12 @@ class ParentModuleTests(unittest.TestCase):
# This raises ImportError on the "from . import module"
# line, not sure why.
import_util
.
import_
(
'pkg'
)
self
.
assert
False
(
'pkg'
in
sys
.
modules
)
self
.
assert
NotIn
(
'pkg'
,
sys
.
modules
)
with
self
.
assertRaises
((
ZeroDivisionError
,
ImportError
)):
import_util
.
import_
(
'pkg.module'
)
self
.
assert
False
(
'pkg'
in
sys
.
modules
)
self
.
assert
NotIn
(
'pkg'
,
sys
.
modules
)
# XXX False
#self.assert
True('pkg.module' in
sys.modules)
#self.assert
In('pkg.module',
sys.modules)
def
test_raising_parent_after_double_relative_importing_child
(
self
):
def
__init__
():
...
...
@@ -72,12 +72,12 @@ class ParentModuleTests(unittest.TestCase):
# This raises ImportError on the "from ..subpkg import module"
# line, not sure why.
import_util
.
import_
(
'pkg.subpkg'
)
self
.
assert
False
(
'pkg.subpkg'
in
sys
.
modules
)
self
.
assert
NotIn
(
'pkg.subpkg'
,
sys
.
modules
)
with
self
.
assertRaises
((
ZeroDivisionError
,
ImportError
)):
import_util
.
import_
(
'pkg.subpkg.module'
)
self
.
assert
False
(
'pkg.subpkg'
in
sys
.
modules
)
self
.
assert
NotIn
(
'pkg.subpkg'
,
sys
.
modules
)
# XXX False
#self.assert
True('pkg.subpkg.module' in
sys.modules)
#self.assert
In('pkg.subpkg.module',
sys.modules)
def
test_module_not_package
(
self
):
# Try to import a submodule from a non-package should raise ImportError.
...
...
Lib/importlib/test/import_/test_path.py
View file @
faae3adb
...
...
@@ -20,7 +20,7 @@ class FinderTests(unittest.TestCase):
# Test None returned upon not finding a suitable finder.
module
=
'<test module>'
with
util
.
import_state
():
self
.
assert
True
(
machinery
.
PathFinder
.
find_module
(
module
)
is
None
)
self
.
assert
Is
(
machinery
.
PathFinder
.
find_module
(
module
),
None
)
def
test_sys_path
(
self
):
# Test that sys.path is used when 'path' is None.
...
...
@@ -31,7 +31,7 @@ class FinderTests(unittest.TestCase):
with
util
.
import_state
(
path_importer_cache
=
{
path
:
importer
},
path
=
[
path
]):
loader
=
machinery
.
PathFinder
.
find_module
(
module
)
self
.
assert
True
(
loader
is
importer
)
self
.
assert
Is
(
loader
,
importer
)
def
test_path
(
self
):
# Test that 'path' is used when set.
...
...
@@ -41,7 +41,7 @@ class FinderTests(unittest.TestCase):
importer
=
util
.
mock_modules
(
module
)
with
util
.
import_state
(
path_importer_cache
=
{
path
:
importer
}):
loader
=
machinery
.
PathFinder
.
find_module
(
module
,
[
path
])
self
.
assert
True
(
loader
is
importer
)
self
.
assert
Is
(
loader
,
importer
)
def
test_empty_list
(
self
):
# An empty list should not count as asking for sys.path.
...
...
@@ -61,9 +61,9 @@ class FinderTests(unittest.TestCase):
hook
=
import_util
.
mock_path_hook
(
path
,
importer
=
importer
)
with
util
.
import_state
(
path_hooks
=
[
hook
]):
loader
=
machinery
.
PathFinder
.
find_module
(
module
,
[
path
])
self
.
assert
True
(
loader
is
importer
)
self
.
assert
True
(
path
in
sys
.
path_importer_cache
)
self
.
assert
True
(
sys
.
path_importer_cache
[
path
]
is
importer
)
self
.
assert
Is
(
loader
,
importer
)
self
.
assert
In
(
path
,
sys
.
path_importer_cache
)
self
.
assert
Is
(
sys
.
path_importer_cache
[
path
],
importer
)
def
test_empty_path_hooks
(
self
):
# Test that if sys.path_hooks is empty a warning is raised,
...
...
Lib/importlib/test/source/test_abc_loader.py
View file @
faae3adb
...
...
@@ -221,7 +221,7 @@ class PyLoaderTests(testing_abc.LoaderTests):
mock
=
self
.
mocker
({
name
:
path
})
with
util
.
uncache
(
name
):
module
=
mock
.
load_module
(
name
)
self
.
assert
True
(
name
in
sys
.
modules
)
self
.
assert
In
(
name
,
sys
.
modules
)
self
.
eq_attrs
(
module
,
__name__
=
name
,
__file__
=
path
,
__package__
=
''
,
__loader__
=
mock
)
self
.
assertTrue
(
not
hasattr
(
module
,
'__path__'
))
...
...
@@ -233,7 +233,7 @@ class PyLoaderTests(testing_abc.LoaderTests):
mock
=
self
.
mocker
({
name
:
path
})
with
util
.
uncache
(
name
):
module
=
mock
.
load_module
(
name
)
self
.
assert
True
(
name
in
sys
.
modules
)
self
.
assert
In
(
name
,
sys
.
modules
)
self
.
eq_attrs
(
module
,
__name__
=
name
,
__file__
=
path
,
__path__
=
[
os
.
path
.
dirname
(
path
)],
__package__
=
name
,
__loader__
=
mock
)
...
...
@@ -259,8 +259,8 @@ class PyLoaderTests(testing_abc.LoaderTests):
with
util
.
uncache
(
name
):
sys
.
modules
[
name
]
=
module
loaded_module
=
mock
.
load_module
(
name
)
self
.
assert
True
(
loaded_module
is
module
)
self
.
assert
True
(
sys
.
modules
[
name
]
is
module
)
self
.
assert
Is
(
loaded_module
,
module
)
self
.
assert
Is
(
sys
.
modules
[
name
],
module
)
return
mock
,
name
def
test_state_after_failure
(
self
):
...
...
@@ -273,7 +273,7 @@ class PyLoaderTests(testing_abc.LoaderTests):
sys
.
modules
[
name
]
=
module
with
self
.
assertRaises
(
ZeroDivisionError
):
mock
.
load_module
(
name
)
self
.
assert
True
(
sys
.
modules
[
name
]
is
module
)
self
.
assert
Is
(
sys
.
modules
[
name
],
module
)
self
.
assertTrue
(
hasattr
(
module
,
'blah'
))
return
mock
...
...
@@ -284,7 +284,7 @@ class PyLoaderTests(testing_abc.LoaderTests):
with
util
.
uncache
(
name
):
with
self
.
assertRaises
(
ZeroDivisionError
):
mock
.
load_module
(
name
)
self
.
assert
True
(
name
not
in
sys
.
modules
)
self
.
assert
NotIn
(
name
,
sys
.
modules
)
return
mock
...
...
@@ -414,8 +414,7 @@ class SkipWritingBytecodeTests(unittest.TestCase):
sys
.
dont_write_bytecode
=
dont_write_bytecode
with
util
.
uncache
(
name
):
mock
.
load_module
(
name
)
self
.
assertTrue
((
name
in
mock
.
module_bytecode
)
is
not
dont_write_bytecode
)
self
.
assertIsNot
(
name
in
mock
.
module_bytecode
,
dont_write_bytecode
)
def
test_no_bytecode_written
(
self
):
self
.
run_test
(
True
)
...
...
@@ -440,7 +439,7 @@ class RegeneratedBytecodeTests(unittest.TestCase):
'magic'
:
bad_magic
}})
with
util
.
uncache
(
name
):
mock
.
load_module
(
name
)
self
.
assert
True
(
name
in
mock
.
module_bytecode
)
self
.
assert
In
(
name
,
mock
.
module_bytecode
)
magic
=
mock
.
module_bytecode
[
name
][:
4
]
self
.
assertEqual
(
magic
,
imp
.
get_magic
())
...
...
@@ -453,7 +452,7 @@ class RegeneratedBytecodeTests(unittest.TestCase):
{
name
:
{
'path'
:
'path/to/mod.bytecode'
,
'mtime'
:
old_mtime
}})
with
util
.
uncache
(
name
):
mock
.
load_module
(
name
)
self
.
assert
True
(
name
in
mock
.
module_bytecode
)
self
.
assert
In
(
name
,
mock
.
module_bytecode
)
mtime
=
importlib
.
_r_long
(
mock
.
module_bytecode
[
name
][
4
:
8
])
self
.
assertEqual
(
mtime
,
PyPycLoaderMock
.
default_mtime
)
...
...
@@ -621,7 +620,7 @@ class SourceOnlyLoaderTests(SourceLoaderTestHarness):
module
=
self
.
loader
.
load_module
(
self
.
name
)
self
.
verify_module
(
module
)
self
.
assertEqual
(
module
.
__path__
,
[
os
.
path
.
dirname
(
self
.
path
)])
self
.
assert
True
(
self
.
name
in
sys
.
modules
)
self
.
assert
In
(
self
.
name
,
sys
.
modules
)
def
test_package_settings
(
self
):
# __package__ needs to be set, while __path__ is set on if the module
...
...
Lib/importlib/test/source/test_file_loader.py
View file @
faae3adb
...
...
@@ -64,7 +64,7 @@ class SimpleTest(unittest.TestCase):
with
source_util
.
create_modules
(
'_temp'
)
as
mapping
:
loader
=
_bootstrap
.
SourceFileLoader
(
'_temp'
,
mapping
[
'_temp'
])
module
=
loader
.
load_module
(
'_temp'
)
self
.
assert
True
(
'_temp'
in
sys
.
modules
)
self
.
assert
In
(
'_temp'
,
sys
.
modules
)
check
=
{
'__name__'
:
'_temp'
,
'__file__'
:
mapping
[
'_temp'
],
'__package__'
:
''
}
for
attr
,
value
in
check
.
items
():
...
...
@@ -75,7 +75,7 @@ class SimpleTest(unittest.TestCase):
loader
=
_bootstrap
.
SourceFileLoader
(
'_pkg'
,
mapping
[
'_pkg.__init__'
])
module
=
loader
.
load_module
(
'_pkg'
)
self
.
assert
True
(
'_pkg'
in
sys
.
modules
)
self
.
assert
In
(
'_pkg'
,
sys
.
modules
)
check
=
{
'__name__'
:
'_pkg'
,
'__file__'
:
mapping
[
'_pkg.__init__'
],
'__path__'
:
[
os
.
path
.
dirname
(
mapping
[
'_pkg.__init__'
])],
'__package__'
:
'_pkg'
}
...
...
@@ -88,7 +88,7 @@ class SimpleTest(unittest.TestCase):
loader
=
_bootstrap
.
SourceFileLoader
(
'_pkg.mod'
,
mapping
[
'_pkg.mod'
])
module
=
loader
.
load_module
(
'_pkg.mod'
)
self
.
assert
True
(
'_pkg.mod'
in
sys
.
modules
)
self
.
assert
In
(
'_pkg.mod'
,
sys
.
modules
)
check
=
{
'__name__'
:
'_pkg.mod'
,
'__file__'
:
mapping
[
'_pkg.mod'
],
'__package__'
:
'_pkg'
}
for
attr
,
value
in
check
.
items
():
...
...
@@ -107,7 +107,7 @@ class SimpleTest(unittest.TestCase):
with
open
(
mapping
[
'_temp'
],
'w'
)
as
file
:
file
.
write
(
"testing_var = 42
\
n
"
)
module
=
loader
.
load_module
(
'_temp'
)
self
.
assert
True
(
'testing_var'
in
module
.
__dict__
,
self
.
assert
In
(
'testing_var'
,
module
.
__dict__
,
"'testing_var' not in "
"{0}"
.
format
(
list
(
module
.
__dict__
.
keys
())))
self
.
assertEqual
(
module
,
sys
.
modules
[
'_temp'
])
...
...
@@ -139,7 +139,7 @@ class SimpleTest(unittest.TestCase):
loader
=
_bootstrap
.
SourceFileLoader
(
'_temp'
,
mapping
[
'_temp'
])
with
self
.
assertRaises
(
SyntaxError
):
loader
.
load_module
(
'_temp'
)
self
.
assert
True
(
'_temp'
not
in
sys
.
modules
)
self
.
assert
NotIn
(
'_temp'
,
sys
.
modules
)
def
test_file_from_empty_string_dir
(
self
):
# Loading a module found from an empty string entry on sys.path should
...
...
@@ -189,7 +189,7 @@ class BadBytecodeTest(unittest.TestCase):
def
import_
(
self
,
file
,
module_name
):
loader
=
self
.
loader
(
module_name
,
file
)
module
=
loader
.
load_module
(
module_name
)
self
.
assert
True
(
module_name
in
sys
.
modules
)
self
.
assert
In
(
module_name
,
sys
.
modules
)
def
manipulate_bytecode
(
self
,
name
,
mapping
,
manipulator
,
*
,
del_source
=
False
):
...
...
Lib/importlib/test/source/test_finder.py
View file @
faae3adb
...
...
@@ -115,7 +115,7 @@ class FinderTests(abc.FinderTests):
def
test_failure
(
self
):
with
source_util
.
create_modules
(
'blah'
)
as
mapping
:
nothing
=
self
.
import_
(
mapping
[
'.root'
],
'sdfsadsadf'
)
self
.
assert
True
(
nothing
is
None
)
self
.
assert
Is
(
nothing
,
None
)
def
test_empty_string_for_dir
(
self
):
# The empty string from sys.path means to search in the cwd.
...
...
Lib/importlib/test/test_util.py
View file @
faae3adb
...
...
@@ -29,8 +29,8 @@ class ModuleForLoaderTests(unittest.TestCase):
module_name
=
'a.b.c'
with
test_util
.
uncache
(
module_name
):
module
=
self
.
return_module
(
module_name
)
self
.
assert
True
(
module_name
in
sys
.
modules
)
self
.
assert
True
(
isinstance
(
module
,
types
.
ModuleType
)
)
self
.
assert
In
(
module_name
,
sys
.
modules
)
self
.
assert
IsInstance
(
module
,
types
.
ModuleType
)
self
.
assertEqual
(
module
.
__name__
,
module_name
)
def
test_reload
(
self
):
...
...
@@ -48,7 +48,7 @@ class ModuleForLoaderTests(unittest.TestCase):
name
=
'a.b.c'
with
test_util
.
uncache
(
name
):
self
.
raise_exception
(
name
)
self
.
assert
True
(
name
not
in
sys
.
modules
)
self
.
assert
NotIn
(
name
,
sys
.
modules
)
def
test_reload_failure
(
self
):
# Test that a failure on reload leaves the module in-place.
...
...
@@ -77,7 +77,7 @@ class ModuleForLoaderTests(unittest.TestCase):
self
.
assertFalse
(
module
)
sys
.
modules
[
name
]
=
module
given
=
self
.
return_module
(
name
)
self
.
assert
True
(
given
is
module
)
self
.
assert
Is
(
given
,
module
)
def
test_attributes_set
(
self
):
# __name__, __loader__, and __package__ should be set (when
...
...
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