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

Function parse_testfile

Lib/test/test_math.py:102–123  ·  view source on GitHub ↗

Parse a file with test values Empty lines or lines starting with -- are ignored yields id, fn, arg_real, arg_imag, exp_real, exp_imag

(fname)

Source from the content-addressed store, hash-verified

100
101
102def parse_testfile(fname):
103 """Parse a file with test values
104
105 Empty lines or lines starting with -- are ignored
106 yields id, fn, arg_real, arg_imag, exp_real, exp_imag
107 """
108 with open(fname, encoding="utf-8") as fp:
109 for line in fp:
110 # skip comment lines and blank lines
111 if line.startswith('--') or not line.strip():
112 continue
113
114 lhs, rhs = line.split('->')
115 id, fn, arg_real, arg_imag = lhs.split()
116 rhs_pieces = rhs.split()
117 exp_real, exp_imag = rhs_pieces[0], rhs_pieces[1]
118 flags = rhs_pieces[2:]
119
120 yield (id, fn,
121 float(arg_real), float(arg_imag),
122 float(exp_real), float(exp_imag),
123 flags)
124
125
126def result_check(expected, got, ulp_tol=5, abs_tol=0.0):

Callers 2

test_specific_valuesMethod · 0.90
test_testfileMethod · 0.85

Calls 4

openFunction · 0.50
startswithMethod · 0.45
stripMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…