(self)
| 2083 | |
| 2084 | @requires_IEEE_754 |
| 2085 | def test_testfile(self): |
| 2086 | # Some tests need to be skipped on ancient OS X versions. |
| 2087 | # See issue #27953. |
| 2088 | SKIP_ON_TIGER = {'tan0064'} |
| 2089 | |
| 2090 | osx_version = None |
| 2091 | if sys.platform == 'darwin': |
| 2092 | version_txt = platform.mac_ver()[0] |
| 2093 | try: |
| 2094 | osx_version = tuple(map(int, version_txt.split('.'))) |
| 2095 | except ValueError: |
| 2096 | pass |
| 2097 | |
| 2098 | fail_fmt = "{}: {}({!r}): {}" |
| 2099 | |
| 2100 | failures = [] |
| 2101 | for id, fn, ar, ai, er, ei, flags in parse_testfile(test_file): |
| 2102 | # Skip if either the input or result is complex |
| 2103 | if ai != 0.0 or ei != 0.0: |
| 2104 | continue |
| 2105 | if fn in ['rect', 'polar']: |
| 2106 | # no real versions of rect, polar |
| 2107 | continue |
| 2108 | # Skip certain tests on OS X 10.4. |
| 2109 | if osx_version is not None and osx_version < (10, 5): |
| 2110 | if id in SKIP_ON_TIGER: |
| 2111 | continue |
| 2112 | |
| 2113 | func = getattr(math, fn) |
| 2114 | |
| 2115 | if 'invalid' in flags or 'divide-by-zero' in flags: |
| 2116 | er = 'ValueError' |
| 2117 | elif 'overflow' in flags: |
| 2118 | er = 'OverflowError' |
| 2119 | |
| 2120 | try: |
| 2121 | result = func(ar) |
| 2122 | except ValueError: |
| 2123 | result = 'ValueError' |
| 2124 | except OverflowError: |
| 2125 | result = 'OverflowError' |
| 2126 | |
| 2127 | # C99+ says for math.h's sqrt: If the argument is +∞ or ±0, it is |
| 2128 | # returned, unmodified. On another hand, for csqrt: If z is ±0+0i, |
| 2129 | # the result is +0+0i. Lets correct zero sign of er to follow |
| 2130 | # first convention. |
| 2131 | if id in ['sqrt0002', 'sqrt0003', 'sqrt1001', 'sqrt1023']: |
| 2132 | er = math.copysign(er, ar) |
| 2133 | |
| 2134 | # Default tolerances |
| 2135 | ulp_tol, abs_tol = 5, 0.0 |
| 2136 | |
| 2137 | failure = result_check(er, result, ulp_tol, abs_tol) |
| 2138 | if failure is None: |
| 2139 | continue |
| 2140 | |
| 2141 | msg = fail_fmt.format(id, fn, ar, failure) |
| 2142 | failures.append(msg) |
nothing calls this directly
no test coverage detected