MCPcopy Create free account
hub / github.com/pytest-dev/pytest / _rewrite_test

Function _rewrite_test

src/_pytest/assertion/rewrite.py:357–365  ·  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

355
356
357def _rewrite_test(fn: Path, config: Config) -> Tuple[os.stat_result, types.CodeType]:
358 """Read and rewrite *fn* and return the code object."""
359 stat = os.stat(fn)
360 source = fn.read_bytes()
361 strfn = str(fn)
362 tree = ast.parse(source, filename=strfn)
363 rewrite_asserts(tree, source, strfn, config)
364 co = compile(tree, strfn, "exec", dont_inherit=True)
365 return stat, co
366
367
368def _read_pyc(

Callers 2

test_read_pyc_successMethod · 0.90
exec_moduleMethod · 0.85

Calls 2

rewrite_assertsFunction · 0.85
parseMethod · 0.45

Tested by 1

test_read_pyc_successMethod · 0.72