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

Function parse_testfile

Lib/test/test_math.py:151–172  ·  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

149
150
151def parse_testfile(fname):
152 """Parse a file with test values
153
154 Empty lines or lines starting with -- are ignored
155 yields id, fn, arg_real, arg_imag, exp_real, exp_imag
156 """
157 with open(fname, encoding="utf-8") as fp:
158 for line in fp:
159 # skip comment lines and blank lines
160 if line.startswith('--') or not line.strip():
161 continue
162
163 lhs, rhs = line.split('->')
164 id, fn, arg_real, arg_imag = lhs.split()
165 rhs_pieces = rhs.split()
166 exp_real, exp_imag = rhs_pieces[0], rhs_pieces[1]
167 flags = rhs_pieces[2:]
168
169 yield (id, fn,
170 float(arg_real), float(arg_imag),
171 float(exp_real), float(exp_imag),
172 flags)
173
174
175def 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