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

Function test_from_float

Modules/_decimal/tests/deccheck.py:1081–1095  ·  view source on GitHub ↗

Iterate the __float__ method through many test cases.

(method, prec, exprange, restricted_range, itr, stat)

Source from the content-addressed store, hash-verified

1079 log(err)
1080
1081def test_from_float(method, prec, exprange, restricted_range, itr, stat):
1082 """Iterate the __float__ method through many test cases."""
1083 for rounding in RoundModes:
1084 context.rounding = rounding
1085 for i in range(1000):
1086 f = randfloat()
1087 op = (f,) if method.startswith("context.") else ("sNaN", f)
1088 t = TestSet(method, op)
1089 try:
1090 if not convert(t):
1091 continue
1092 callfuncs(t)
1093 verify(t, stat)
1094 except VerifyError as err:
1095 log(err)
1096
1097def randcontext(exprange):
1098 c = Context(C.Context(), P.Context())

Callers

nothing calls this directly

Calls 7

randfloatFunction · 0.90
callfuncsFunction · 0.85
TestSetClass · 0.70
convertFunction · 0.70
verifyFunction · 0.70
logFunction · 0.70
startswithMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…