Kaydet (Commit) ae9ad186 authored tarafından Brett Cannon's avatar Brett Cannon

Do not execute the .pyc/.pyo files as well as the .py files.

üst 4ee2cdaf
...@@ -9,7 +9,8 @@ def test_suite(package=__package__, directory=os.path.dirname(__file__)): ...@@ -9,7 +9,8 @@ def test_suite(package=__package__, directory=os.path.dirname(__file__)):
if name.startswith('.'): if name.startswith('.'):
continue continue
path = os.path.join(directory, name) 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] submodule_name = os.path.splitext(name)[0]
module_name = "{0}.{1}".format(package, submodule_name) module_name = "{0}.{1}".format(package, submodule_name)
__import__(module_name, level=0) __import__(module_name, level=0)
...@@ -20,6 +21,8 @@ def test_suite(package=__package__, directory=os.path.dirname(__file__)): ...@@ -20,6 +21,8 @@ def test_suite(package=__package__, directory=os.path.dirname(__file__)):
__import__(package_name, level=0) __import__(package_name, level=0)
package_tests = getattr(sys.modules[package_name], 'test_suite')() package_tests = getattr(sys.modules[package_name], 'test_suite')()
suite.addTest(package_tests) suite.addTest(package_tests)
else:
continue
return suite return suite
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment