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