Ticket #6712: svn.diff

File svn.diff, 1.4 KB (added by alainD, 17 years ago)

diff file (modified file is django/test/simple.py)

  • django/test/simple.py

     
    7373                pass
    7474    return suite
    7575
     76def _get_all_tests_from_suite(suite):
     77    """Explore suite recursively to get _all_ tests in it
     78    """
     79    if isinstance(suite,unittest.TestCase):
     80        return [suite]
     81    else:
     82        all_tests = []
     83        [all_tests.extend(_get_all_tests_from_suite(sub_suite)) for sub_suite in getattr(suite,'_tests',[])]
     84        return all_tests
     85
    7686def build_test(label):
    7787    """Construct a test case a test with the specified label. Label should
    7888    be of the form model.TestClass or model.TestClass.test_method. Returns
     
    92102        if test_module:
    93103            TestClass = getattr(test_module, parts[1], None)
    94104
     105    # Couldn't find the test class; look in test suite
     106    if TestClass is None:
     107        suite = build_suite(app_module)
     108        all_tests = _get_all_tests_from_suite(suite)
     109        for test_in_suite in all_tests:
     110            if test_in_suite.__class__.__name__ == parts[1]:
     111                TestClass = test_in_suite.__class__
     112                break
     113
    95114    if len(parts) == 2: # label is app.TestClass
    96115        try:
    97116            return unittest.TestLoader().loadTestsFromTestCase(TestClass)
Back to Top