/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-03-01 23:07:35 UTC
  • mfrom: (779.1.2 setup-fix)
  • Revision ID: sinzui.is@verizon.net-20120301230735-81kmzh3xsku51ryi
Fix selftest.

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(module_or_name):
 
27
    if isinstance(module_or_name, basestring):
 
28
        match = module_or_name
 
29
    else:
 
30
        match = ''
 
31
    file_names = os.listdir(os.path.dirname(__file__))
 
32
    test_names = set()
 
33
    for file_name in file_names:
 
34
        name, ext = os.path.splitext(file_name)
 
35
        if name.startswith('test_') and ext == '.py' and match in name:
 
36
            test_names.add("%s.%s" % (__name__, name))
 
37
    return test_names
 
38
 
 
39
 
26
40
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))
30
 
    else:
31
 
        full_name = "%s.%s" % (__name__, module)
32
 
        basic_tests.addTest(loader.loadTestsFromModuleNames([full_name]))
 
41
    test_names = discover_test_names(module)
 
42
    basic_tests.addTest(loader.loadTestsFromModuleNames(test_names))
33
43
    return basic_tests
34
44
 
35
45