diff options
author | Brett Cannon <bcannon@gmail.com> | 2009-02-01 03:51:54 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2009-02-01 03:51:54 (GMT) |
commit | ae9ad186d058c5700d0692e2f3b026e95639f5cf (patch) | |
tree | 64e9312d1b7379d4016c4388ea115fcbd0c5773f | |
parent | 4ee2cdaf65971391b35ce7aaad5ce77ddcbb176e (diff) | |
download | cpython-ae9ad186d058c5700d0692e2f3b026e95639f5cf.zip cpython-ae9ad186d058c5700d0692e2f3b026e95639f5cf.tar.gz cpython-ae9ad186d058c5700d0692e2f3b026e95639f5cf.tar.bz2 |
Do not execute the .pyc/.pyo files as well as the .py files.
-rw-r--r-- | Lib/importlib/test/__init__.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/importlib/test/__init__.py b/Lib/importlib/test/__init__.py index f9dd57e..bda33e6 100644 --- a/Lib/importlib/test/__init__.py +++ b/Lib/importlib/test/__init__.py @@ -9,7 +9,8 @@ def test_suite(package=__package__, directory=os.path.dirname(__file__)): if name.startswith('.'): continue path = os.path.join(directory, name) - if os.path.isfile(path) and name.startswith('test_'): + if (os.path.isfile(path) and name.startswith('test_') and + name.endswith('.py')): submodule_name = os.path.splitext(name)[0] module_name = "{0}.{1}".format(package, submodule_name) __import__(module_name, level=0) @@ -20,6 +21,8 @@ def test_suite(package=__package__, directory=os.path.dirname(__file__)): __import__(package_name, level=0) package_tests = getattr(sys.modules[package_name], 'test_suite')() suite.addTest(package_tests) + else: + continue return suite |