Read and rewrite *fn* and return the code object.
(fn: Path, config: Config)
| 355 | |
| 356 | |
| 357 | def _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 | |
| 368 | def _read_pyc( |