MCPcopy Index your code
hub / github.com/pre-commit/pre-commit / test_invalidated_virtualenv

Function test_invalidated_virtualenv

tests/repository_test.py:268–290  ·  view source on GitHub ↗
(tempdir_factory, store)

Source from the content-addressed store, hash-verified

266
267
268def test_invalidated_virtualenv(tempdir_factory, store):
269 # A cached virtualenv may become invalidated if the system python upgrades
270 # This should not cause every hook in that virtualenv to fail.
271 path = make_repo(tempdir_factory, 'python_hooks_repo')
272 config = make_config_from_repo(path)
273 hook = _get_hook(config, store, 'foo')
274
275 # Simulate breaking of the virtualenv
276 envdir = lang_base.environment_dir(
277 hook.prefix,
278 python.ENVIRONMENT_DIR,
279 hook.language_version,
280 )
281 libdir = os.path.join(envdir, 'lib', hook.language_version)
282 paths = [
283 os.path.join(libdir, p) for p in ('site.py', 'site.pyc', '__pycache__')
284 ]
285 cmd_output_b('rm', '-rf', *paths)
286
287 # pre-commit should rebuild the virtualenv and it should be runnable
288 hook = _get_hook(config, store, 'foo')
289 ret, out = _hook_run(hook, (), color=False)
290 assert ret == 0
291
292
293def test_really_long_file_paths(tempdir_factory, store):

Callers

nothing calls this directly

Calls 5

make_repoFunction · 0.90
make_config_from_repoFunction · 0.90
cmd_output_bFunction · 0.90
_get_hookFunction · 0.85
_hook_runFunction · 0.85

Tested by

no test coverage detected