MCPcopy
hub / github.com/pytest-dev/pytest / _rewrite_test

Function _rewrite_test

src/_pytest/assertion/rewrite.py:343–351  ·  view source on GitHub ↗

Read and rewrite *fn* and return the code object.

(fn: Path, config: Config)

Source from the content-addressed store, hash-verified

341
342
343def _rewrite_test(fn: Path, config: Config) -> tuple[os.stat_result, types.CodeType]:
344 """Read and rewrite *fn* and return the code object."""
345 stat = os.stat(fn)
346 source = fn.read_bytes()
347 strfn = str(fn)
348 tree = ast.parse(source, filename=strfn)
349 rewrite_asserts(tree, source, strfn, config)
350 co = compile(tree, strfn, "exec", dont_inherit=True)
351 return stat, co
352
353
354def _read_pyc(

Callers 2

test_read_pyc_successMethod · 0.90
exec_moduleMethod · 0.85

Calls 3

rewrite_assertsFunction · 0.85
statMethod · 0.80
parseMethod · 0.45

Tested by 1

test_read_pyc_successMethod · 0.72