~testdoc-dev/testdoc/trunk.git

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Copyright (c) 2007-2010 testdoc authors. See LICENSE for details.

import inspect

from testdoc import reflect


def get_lineno(obj):
    return inspect.getsourcelines(obj)[1]


def find_tests(finder, module):
    finder.got_module(module)
    classes = sorted(reflect.findTestClasses(module), key=get_lineno)
    for testCaseClass in classes:
        finder.got_test_class(testCaseClass)
        methods = [getattr(testCaseClass, 'test%s' % name)
                   for name in reflect.getTestCaseNames(testCaseClass)]
        for method in sorted(methods, key=get_lineno):
            finder.got_test(method)