mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Add initial implementation of importlib. See the NOTES files for what is
planned for the package. There are no docs yet, but they are coming once the API for the first new function, importlib.import_module() is finalized.
This commit is contained in:
parent
458ad47a2c
commit
23cbd8a656
35 changed files with 3360 additions and 0 deletions
26
Lib/importlib/test/__init__.py
Normal file
26
Lib/importlib/test/__init__.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
import os.path
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
|
||||
def test_suite(package=__package__, directory=os.path.dirname(__file__)):
|
||||
suite = unittest.TestSuite()
|
||||
for name in os.listdir(directory):
|
||||
path = os.path.join(directory, name)
|
||||
if os.path.isfile(path) and name.startswith('test_'):
|
||||
submodule_name = os.path.splitext(name)[0]
|
||||
module_name = "{0}.{1}".format(package, submodule_name)
|
||||
__import__(module_name, level=0)
|
||||
module_tests = unittest.findTestCases(sys.modules[module_name])
|
||||
suite.addTest(module_tests)
|
||||
elif os.path.isdir(path):
|
||||
package_name = "{0}.{1}".format(package, name)
|
||||
__import__(package_name, level=0)
|
||||
package_tests = getattr(sys.modules[package_name], 'test_suite')()
|
||||
suite.addTest(package_tests)
|
||||
return suite
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from test.support import run_unittest
|
||||
run_unittest(test_suite('importlib.test'))
|
Loading…
Add table
Add a link
Reference in a new issue