1"""Make tests/ into a package. This allows us to "import tests" and 2have tests.all_tests be a TestSuite representing all test cases 3from all test_*.py files in tests/.""" 4# Author: Collin Winter 5 6import os 7import os.path 8import unittest 9import types 10 11from . import support 12 13all_tests = unittest.TestSuite() 14 15tests_dir = os.path.join(os.path.dirname(__file__), '..', 'tests') 16tests = [t[0:-3] for t in os.listdir(tests_dir) 17 if t.startswith('test_') and t.endswith('.py')] 18 19loader = unittest.TestLoader() 20 21for t in tests: 22 __import__("",globals(),locals(),[t],level=1) 23 mod = globals()[t] 24 all_tests.addTests(loader.loadTestsFromModule(mod)) 25