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

Function get_cache_dir

src/_pytest/assertion/rewrite.py:1123–1134  ·  view source on GitHub ↗

Return the cache directory to write .pyc files for the given .py file path.

(file_path: Path)

Source from the content-addressed store, hash-verified

1121
1122
1123def get_cache_dir(file_path: Path) -> Path:
1124 """Return the cache directory to write .pyc files for the given .py file path."""
1125 if sys.version_info >= (3, 8) and sys.pycache_prefix:
1126 # given:
1127 # prefix = '/tmp/pycs'
1128 # path = '/home/user/proj/test_app.py'
1129 # we want:
1130 # '/tmp/pycs/home/user/proj'
1131 return Path(sys.pycache_prefix) / Path(*file_path.parts[1:-1])
1132 else:
1133 # classic pycache directory
1134 return file_path.parent / "__pycache__"

Callers 3

test_get_cache_dirMethod · 0.90
exec_moduleMethod · 0.85

Calls

no outgoing calls

Tested by 2

test_get_cache_dirMethod · 0.72