diff --git a/_pytest/assertion.py b/_pytest/assertion.py index 2d760381f..be5ac2d3f 100644 --- a/_pytest/assertion.py +++ b/_pytest/assertion.py @@ -43,6 +43,23 @@ def pytest_configure(config): else: rewrite_asserts = None +def _write_pyc(co, source_path): + if hasattr(imp, "cache_from_source"): + # Handle PEP 3147 pycs. + pyc = py.path(imp.cache_from_source(source_math)) + pyc.dirname.ensure(dir=True) + else: + pyc = source_path + "c" + mtime = int(source_path.mtime()) + fp = pyc.open("wb") + try: + fp.write(imp.get_magic()) + fp.write(struct.pack("