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

Function _write_pyc

src/_pytest/assertion/rewrite.py:310–325  ·  view source on GitHub ↗
(
        state: "AssertionState",
        co: types.CodeType,
        source_stat: os.stat_result,
        pyc: Path,
    )

Source from the content-addressed store, hash-verified

308 from atomicwrites import atomic_write
309
310 def _write_pyc(
311 state: "AssertionState",
312 co: types.CodeType,
313 source_stat: os.stat_result,
314 pyc: Path,
315 ) -> bool:
316 try:
317 with atomic_write(os.fspath(pyc), mode="wb", overwrite=True) as fp:
318 _write_pyc_fp(fp, source_stat, co)
319 except OSError as e:
320 state.trace(f"error writing pyc file at {pyc}: {e}")
321 # we ignore any failure to write the cache file
322 # there are many reasons, permission-denied, pycache dir being a
323 # file etc.
324 return False
325 return True
326
327
328else:

Callers 3

test_write_pycMethod · 0.90
test_read_pyc_successMethod · 0.90
exec_moduleMethod · 0.85

Calls 4

_write_pyc_fpFunction · 0.85
fspathMethod · 0.80
traceMethod · 0.80
closeMethod · 0.45

Tested by 2

test_write_pycMethod · 0.72
test_read_pyc_successMethod · 0.72