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

Function test_cd

tests/commands/hazmat_test.py:48–67  ·  view source on GitHub ↗
(tmp_path, capfd)

Source from the content-addressed store, hash-verified

46
47
48def test_cd(tmp_path, capfd):
49 subdir = tmp_path.joinpath('subdir')
50 subdir.mkdir()
51 subdir.joinpath('a').write_text('a')
52 subdir.joinpath('b').write_text('b')
53
54 with cwd(tmp_path):
55 ret = main((
56 'cd', 'subdir',
57 sys.executable, '-c',
58 'import os; print(os.getcwd());'
59 'import sys; [print(open(f).read()) for f in sys.argv[1:]]',
60 '--',
61 'subdir/a', 'subdir/b',
62 ))
63
64 assert ret == 0
65 out, err = capfd.readouterr()
66 assert _norm(out) == f'{subdir}\na\nb\n'
67 assert err == ''
68
69
70def test_ignore_exit_code(capfd):

Callers

nothing calls this directly

Calls 3

cwdFunction · 0.90
mainFunction · 0.90
_normFunction · 0.70

Tested by

no test coverage detected