Ticket #6712: svn.diff
File svn.diff, 1.4 KB (added by , 17 years ago) |
---|
-
django/test/simple.py
73 73 pass 74 74 return suite 75 75 76 def _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 76 86 def build_test(label): 77 87 """Construct a test case a test with the specified label. Label should 78 88 be of the form model.TestClass or model.TestClass.test_method. Returns … … 92 102 if test_module: 93 103 TestClass = getattr(test_module, parts[1], None) 94 104 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 95 114 if len(parts) == 2: # label is app.TestClass 96 115 try: 97 116 return unittest.TestLoader().loadTestsFromTestCase(TestClass)