mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Issue #22173: Update lib2to3 tests to use unittest test discovery.
This commit is contained in:
parent
b7354a65ce
commit
2acbae8016
7 changed files with 19 additions and 38 deletions
|
@ -1,24 +1,9 @@
|
|||
"""Make tests/ into a package. This allows us to "import tests" and
|
||||
have tests.all_tests be a TestSuite representing all test cases
|
||||
from all test_*.py files in tests/."""
|
||||
# Author: Collin Winter
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import unittest
|
||||
import types
|
||||
|
||||
from . import support
|
||||
from test.support import load_package_tests
|
||||
|
||||
all_tests = unittest.TestSuite()
|
||||
|
||||
tests_dir = os.path.join(os.path.dirname(__file__), '..', 'tests')
|
||||
tests = [t[0:-3] for t in os.listdir(tests_dir)
|
||||
if t.startswith('test_') and t.endswith('.py')]
|
||||
|
||||
loader = unittest.TestLoader()
|
||||
|
||||
for t in tests:
|
||||
__import__("",globals(),locals(),[t],level=1)
|
||||
mod = globals()[t]
|
||||
all_tests.addTests(loader.loadTestsFromModule(mod))
|
||||
def load_tests(*args):
|
||||
return load_package_tests(os.path.dirname(__file__), *args)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue