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

Function test_method

Modules/_decimal/tests/deccheck.py:930–961  ·  view source on GitHub ↗

Iterate a test function through many context settings.

(method, testspecs, testfunc)

Source from the content-addressed store, hash-verified

928 sys.stdout.flush()
929
930def test_method(method, testspecs, testfunc):
931 """Iterate a test function through many context settings."""
932 log("testing %s ...", method)
933 stat = defaultdict(int)
934 for spec in testspecs:
935 if 'samples' in spec:
936 spec['prec'] = sorted(random.sample(range(1, 101),
937 spec['samples']))
938 for prec in spec['prec']:
939 context.prec = prec
940 for expts in spec['expts']:
941 emin, emax = expts
942 if emin == 'rand':
943 context.Emin = random.randrange(-1000, 0)
944 context.Emax = random.randrange(prec, 1000)
945 else:
946 context.Emin, context.Emax = emin, emax
947 if prec > context.Emax: continue
948 log(" prec: %d emin: %d emax: %d",
949 (context.prec, context.Emin, context.Emax))
950 restr_range = 9999 if context.Emax > 9999 else context.Emax+99
951 for rounding in RoundModes:
952 context.rounding = rounding
953 context.capitals = random.randrange(2)
954 if spec['clamp'] == 'rand':
955 context.clamp = random.randrange(2)
956 else:
957 context.clamp = spec['clamp']
958 exprange = context.c.Emax
959 testfunc(method, prec, exprange, restr_range,
960 spec['iter'], stat)
961 log(" result types: %s" % sorted([t for t in stat.items()]))
962
963def test_unary(method, prec, exp_range, restricted_range, itr, stat):
964 """Iterate a unary function through many test cases."""

Callers 2

new_test_methodFunction · 0.85
deccheck.pyFile · 0.85

Calls 6

defaultdictClass · 0.85
testfuncFunction · 0.85
randrangeMethod · 0.80
logFunction · 0.70
sampleMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…