mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Split out support code that is specific to source tests out of
importlib.test.support to importlib.test.source.util.
This commit is contained in:
parent
30b047dc35
commit
4ee2cdaf65
8 changed files with 123 additions and 113 deletions
|
@ -1,6 +1,7 @@
|
|||
import importlib
|
||||
from .. import abc
|
||||
from .. import support
|
||||
from . import util as source_util
|
||||
import os
|
||||
import py_compile
|
||||
import unittest
|
||||
|
@ -45,7 +46,7 @@ class FinderTests(abc.FinderTests):
|
|||
"""
|
||||
if create is None:
|
||||
create = {test}
|
||||
with support.create_modules(*create) as mapping:
|
||||
with source_util.create_modules(*create) as mapping:
|
||||
if compile_:
|
||||
for name in compile_:
|
||||
py_compile.compile(mapping[name])
|
||||
|
@ -76,14 +77,14 @@ class FinderTests(abc.FinderTests):
|
|||
|
||||
# [sub module]
|
||||
def test_module_in_package(self):
|
||||
with support.create_modules('pkg.__init__', 'pkg.sub') as mapping:
|
||||
with source_util.create_modules('pkg.__init__', 'pkg.sub') as mapping:
|
||||
pkg_dir = os.path.dirname(mapping['pkg.__init__'])
|
||||
loader = self.import_(pkg_dir, 'pkg.sub')
|
||||
self.assert_(hasattr(loader, 'load_module'))
|
||||
|
||||
# [sub package]
|
||||
def test_package_in_package(self):
|
||||
context = support.create_modules('pkg.__init__', 'pkg.sub.__init__')
|
||||
context = source_util.create_modules('pkg.__init__', 'pkg.sub.__init__')
|
||||
with context as mapping:
|
||||
pkg_dir = os.path.dirname(mapping['pkg.__init__'])
|
||||
loader = self.import_(pkg_dir, 'pkg.sub')
|
||||
|
@ -91,7 +92,7 @@ class FinderTests(abc.FinderTests):
|
|||
|
||||
# [sub empty]
|
||||
def test_empty_sub_directory(self):
|
||||
context = support.create_modules('pkg.__init__', 'pkg.sub.__init__')
|
||||
context = source_util.create_modules('pkg.__init__', 'pkg.sub.__init__')
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("error", ImportWarning)
|
||||
with context as mapping:
|
||||
|
@ -109,7 +110,7 @@ class FinderTests(abc.FinderTests):
|
|||
|
||||
|
||||
def test_failure(self):
|
||||
with support.create_modules('blah') as mapping:
|
||||
with source_util.create_modules('blah') as mapping:
|
||||
nothing = self.import_(mapping['.root'], 'sdfsadsadf')
|
||||
self.assert_(nothing is None)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue