import subprocess def test_python_bytecode_is_not_tracked(): tracked = subprocess.run( ["git", "ls-files"], check=True, capture_output=True, text=True, ).stdout.splitlines() bytecode = [ path for path in tracked if "__pycache__" in path.split("/") or path.endswith((".pyc", ".pyo")) ] assert bytecode == []