(loader, tests, pattern)
| 5936 | |
| 5937 | |
| 5938 | def load_tests(loader, tests, pattern): |
| 5939 | if TODO_TESTS is not None: |
| 5940 | # Run only Arithmetic tests |
| 5941 | tests = loader.suiteClass() |
| 5942 | # Dynamically build custom test definition for each file in the test |
| 5943 | # directory and add the definitions to the DecimalTest class. This |
| 5944 | # procedure insures that new files do not get skipped. |
| 5945 | for filename in os.listdir(directory): |
| 5946 | if '.decTest' not in filename or filename.startswith("."): |
| 5947 | continue |
| 5948 | head, tail = filename.split('.') |
| 5949 | if TODO_TESTS is not None and head not in TODO_TESTS: |
| 5950 | continue |
| 5951 | tester = lambda self, f=filename: self.eval_file(directory + f) |
| 5952 | setattr(IBMTestCases, 'test_' + head, tester) |
| 5953 | del filename, head, tail, tester |
| 5954 | for prefix, mod in ('C', C), ('Py', P): |
| 5955 | if not mod: |
| 5956 | continue |
| 5957 | test_class = type(prefix + 'IBMTestCases', |
| 5958 | (IBMTestCases, unittest.TestCase), |
| 5959 | {'decimal': mod}) |
| 5960 | tests.addTest(loader.loadTestsFromTestCase(test_class)) |
| 5961 | |
| 5962 | if TODO_TESTS is None: |
| 5963 | from doctest import DocTestSuite, IGNORE_EXCEPTION_DETAIL |
| 5964 | orig_context = orig_sys_decimal.getcontext().copy() |
| 5965 | for mod in C, P: |
| 5966 | if not mod: |
| 5967 | continue |
| 5968 | def setUp(slf, mod=mod): |
| 5969 | sys.modules['decimal'] = mod |
| 5970 | init(mod) |
| 5971 | def tearDown(slf, mod=mod): |
| 5972 | sys.modules['decimal'] = orig_sys_decimal |
| 5973 | mod.setcontext(ORIGINAL_CONTEXT[mod].copy()) |
| 5974 | orig_sys_decimal.setcontext(orig_context.copy()) |
| 5975 | optionflags = IGNORE_EXCEPTION_DETAIL if mod is C else 0 |
| 5976 | sys.modules['decimal'] = mod |
| 5977 | tests.addTest(DocTestSuite(mod, setUp=setUp, tearDown=tearDown, |
| 5978 | optionflags=optionflags)) |
| 5979 | sys.modules['decimal'] = orig_sys_decimal |
| 5980 | return tests |
| 5981 | |
| 5982 | def setUpModule(): |
| 5983 | init(C) |
nothing calls this directly
no test coverage detected