MCPcopy Index your code
hub / github.com/python/cpython / load_tests

Function load_tests

Lib/test/test_decimal.py:5955–5997  ·  view source on GitHub ↗
(loader, tests, pattern)

Source from the content-addressed store, hash-verified

5953
5954
5955def load_tests(loader, tests, pattern):
5956 if TODO_TESTS is not None:
5957 # Run only Arithmetic tests
5958 tests = loader.suiteClass()
5959 # Dynamically build custom test definition for each file in the test
5960 # directory and add the definitions to the DecimalTest class. This
5961 # procedure insures that new files do not get skipped.
5962 for filename in os.listdir(directory):
5963 if '.decTest' not in filename or filename.startswith("."):
5964 continue
5965 head, tail = filename.split('.')
5966 if TODO_TESTS is not None and head not in TODO_TESTS:
5967 continue
5968 tester = lambda self, f=filename: self.eval_file(directory + f)
5969 setattr(IBMTestCases, 'test_' + head, tester)
5970 del filename, head, tail, tester
5971 for prefix, mod in ('C', C), ('Py', P):
5972 if not mod:
5973 continue
5974 test_class = type(prefix + 'IBMTestCases',
5975 (IBMTestCases, unittest.TestCase),
5976 {'decimal': mod})
5977 tests.addTest(loader.loadTestsFromTestCase(test_class))
5978
5979 if TODO_TESTS is None:
5980 from doctest import DocTestSuite, IGNORE_EXCEPTION_DETAIL
5981 orig_context = orig_sys_decimal.getcontext().copy()
5982 for mod in C, P:
5983 if not mod:
5984 continue
5985 def setUp(slf, mod=mod):
5986 sys.modules['decimal'] = mod
5987 init(mod)
5988 def tearDown(slf, mod=mod):
5989 sys.modules['decimal'] = orig_sys_decimal
5990 mod.setcontext(ORIGINAL_CONTEXT[mod].copy())
5991 orig_sys_decimal.setcontext(orig_context.copy())
5992 optionflags = IGNORE_EXCEPTION_DETAIL if mod is C else 0
5993 sys.modules['decimal'] = mod
5994 tests.addTest(DocTestSuite(mod, setUp=setUp, tearDown=tearDown,
5995 optionflags=optionflags))
5996 sys.modules['decimal'] = orig_sys_decimal
5997 return tests
5998
5999def setUpModule():
6000 init(C)

Callers

nothing calls this directly

Calls 8

DocTestSuiteFunction · 0.90
listdirMethod · 0.80
eval_fileMethod · 0.80
addTestMethod · 0.80
loadTestsFromTestCaseMethod · 0.80
startswithMethod · 0.45
splitMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…