/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to tests/__init__.py

  • Committer: Curtis Hovey
  • Date: 2012-02-28 17:45:56 UTC
  • mto: This revision was merged to the branch mainline in revision 780.
  • Revision ID: sinzui.is@verizon.net-20120228174556-pf274fas9qcggrqj
Support selftest, check, and check -m

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import os
24
24
 
25
25
 
 
26
def discover_test_names(match=''):
 
27
    file_names = os.listdir(os.path.dirname(__file__))
 
28
    test_names = set()
 
29
    for file_name in file_names:
 
30
        name, ext = os.path.splitext(file_name)
 
31
        if name.startswith('test_') and match in name:
 
32
            test_names.add("%s.%s" % (__name__, name))
 
33
    return test_names
 
34
 
 
35
 
26
36
def load_tests(basic_tests, module, loader):
27
 
    if module == 'discover':
28
 
        here = os.path.abspath(os.path.dirname(__file__))
29
 
        basic_tests.addTest(loader.discover(here))
 
37
    if isinstance(module, basestring):
 
38
        test_names = discover_test_names(match=module)
30
39
    else:
31
 
        full_name = "%s.%s" % (__name__, module)
32
 
        basic_tests.addTest(loader.loadTestsFromModuleNames([full_name]))
 
40
        test_names = discover_test_names()
 
41
    basic_tests.addTest(loader.loadTestsFromModuleNames(test_names))
33
42
    return basic_tests
34
43
 
35
44