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

Function parse_mtestfile

Lib/test/test_math.py:76–99  ·  view source on GitHub ↗

Parse a file with test values -- starts a comment blank lines, or lines containing only a comment, are ignored other lines are expected to have the form id fn arg -> expected [flag]*

(fname)

Source from the content-addressed store, hash-verified

74 return fmt.format(abs_error, ulp_error, abs_tol, ulp_tol)
75
76def parse_mtestfile(fname):
77 """Parse a file with test values
78
79 -- starts a comment
80 blank lines, or lines containing only a comment, are ignored
81 other lines are expected to have the form
82 id fn arg -> expected [flag]*
83
84 """
85 with open(fname, encoding="utf-8") as fp:
86 for line in fp:
87 # strip comments, and skip blank lines
88 if '--' in line:
89 line = line[:line.index('--')]
90 if not line.strip():
91 continue
92
93 lhs, rhs = line.split('->')
94 id, fn, arg = lhs.split()
95 rhs_pieces = rhs.split()
96 exp = rhs_pieces[0]
97 flags = rhs_pieces[1:]
98
99 yield (id, fn, float(arg), float(exp), flags)
100
101
102def parse_testfile(fname):

Callers 1

test_mtestfileMethod · 0.85

Calls 4

openFunction · 0.50
indexMethod · 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…