MCPcopy
hub / github.com/pytest-dev/pytest / get_cache_dir

Function get_cache_dir

src/_pytest/assertion/rewrite.py:1182–1193  ·  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

1180
1181
1182def get_cache_dir(file_path: Path) -> Path:
1183 """Return the cache directory to write .pyc files for the given .py file path."""
1184 if sys.pycache_prefix:
1185 # given:
1186 # prefix = '/tmp/pycs'
1187 # path = '/home/user/proj/test_app.py'
1188 # we want:
1189 # '/tmp/pycs/home/user/proj'
1190 return Path(sys.pycache_prefix) / Path(*file_path.parts[1:-1])
1191 else:
1192 # classic pycache directory
1193 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