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

Method test_testfile

Lib/test/test_math.py:2043–2104  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2041
2042 @requires_IEEE_754
2043 def test_testfile(self):
2044 # Some tests need to be skipped on ancient OS X versions.
2045 # See issue #27953.
2046 SKIP_ON_TIGER = {'tan0064'}
2047
2048 osx_version = None
2049 if sys.platform == 'darwin':
2050 version_txt = platform.mac_ver()[0]
2051 try:
2052 osx_version = tuple(map(int, version_txt.split('.')))
2053 except ValueError:
2054 pass
2055
2056 fail_fmt = "{}: {}({!r}): {}"
2057
2058 failures = []
2059 for id, fn, ar, ai, er, ei, flags in parse_testfile(test_file):
2060 # Skip if either the input or result is complex
2061 if ai != 0.0 or ei != 0.0:
2062 continue
2063 if fn in ['rect', 'polar']:
2064 # no real versions of rect, polar
2065 continue
2066 # Skip certain tests on OS X 10.4.
2067 if osx_version is not None and osx_version < (10, 5):
2068 if id in SKIP_ON_TIGER:
2069 continue
2070
2071 func = getattr(math, fn)
2072
2073 if 'invalid' in flags or 'divide-by-zero' in flags:
2074 er = 'ValueError'
2075 elif 'overflow' in flags:
2076 er = 'OverflowError'
2077
2078 try:
2079 result = func(ar)
2080 except ValueError:
2081 result = 'ValueError'
2082 except OverflowError:
2083 result = 'OverflowError'
2084
2085 # C99+ says for math.h's sqrt: If the argument is +∞ or ±0, it is
2086 # returned, unmodified. On another hand, for csqrt: If z is ±0+0i,
2087 # the result is +0+0i. Lets correct zero sign of er to follow
2088 # first convention.
2089 if id in ['sqrt0002', 'sqrt0003', 'sqrt1001', 'sqrt1023']:
2090 er = math.copysign(er, ar)
2091
2092 # Default tolerances
2093 ulp_tol, abs_tol = 5, 0.0
2094
2095 failure = result_check(er, result, ulp_tol, abs_tol)
2096 if failure is None:
2097 continue
2098
2099 msg = fail_fmt.format(id, fn, ar, failure)
2100 failures.append(msg)

Callers

nothing calls this directly

Calls 9

parse_testfileFunction · 0.85
getattrFunction · 0.85
result_checkFunction · 0.85
funcFunction · 0.70
splitMethod · 0.45
formatMethod · 0.45
appendMethod · 0.45
failMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected