| 46 | |
| 47 | |
| 48 | def 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 | |
| 70 | def test_ignore_exit_code(capfd): |