MCPcopy Index your code
hub / github.com/RustPython/RustPython / loadTestsFromModule

Method loadTestsFromModule

Lib/unittest/loader.py:96–118  ·  view source on GitHub ↗

Return a suite of all test cases contained in the given module

(self, module, *, pattern=None)

Source from the content-addressed store, hash-verified

94 return loaded_suite
95
96 def loadTestsFromModule(self, module, *, pattern=None):
97 """Return a suite of all test cases contained in the given module"""
98 tests = []
99 for name in dir(module):
100 obj = getattr(module, name)
101 if (
102 isinstance(obj, type)
103 and issubclass(obj, case.TestCase)
104 and obj not in (case.TestCase, case.FunctionTestCase)
105 ):
106 tests.append(self.loadTestsFromTestCase(obj))
107
108 load_tests = getattr(module, 'load_tests', None)
109 tests = self.suiteClass(tests)
110 if load_tests is not None:
111 try:
112 return load_tests(self, tests, pattern)
113 except Exception as e:
114 error_case, error_message = _make_failed_load_tests(
115 module.__name__, e, self.suiteClass)
116 self.errors.append(error_message)
117 return error_case
118 return tests
119
120 def loadTestsFromName(self, name, module=None):
121 """Return a suite of all test cases given a string specifier.

Callers 3

loadTestsFromNameMethod · 0.95
_find_test_pathMethod · 0.95
createTestsMethod · 0.45

Calls 8

loadTestsFromTestCaseMethod · 0.95
dirFunction · 0.85
getattrFunction · 0.85
isinstanceFunction · 0.85
issubclassFunction · 0.85
_make_failed_load_testsFunction · 0.85
load_testsFunction · 0.50
appendMethod · 0.45

Tested by

no test coverage detected