|
6 | 6 |
|
7 | 7 | @pytest.mark.parametrize("all_flag", ["", "-A", "--all", "--no-ignore-removal"]) |
8 | 8 | def test_add(git2cpp_path, all_flag): |
| 9 | + checkout_cmd = [git2cpp_path, 'checkout', '-b', 'foregone'] |
| 10 | + subprocess.run(checkout_cmd, cwd="test/data/status_data", text=True) |
| 11 | + |
9 | 12 | with open("./test/mook_file.txt", "x"): |
10 | 13 | pass |
11 | 14 |
|
12 | 15 | cmd_add = [git2cpp_path, 'add', "test/mook_file.txt"] |
13 | | - subprocess.run(cmd_add, capture_output=True, text=True) |
| 16 | + subprocess.run(cmd_add, cwd="test/data/status_data", text=True) |
14 | 17 |
|
15 | 18 | cmd_status = [git2cpp_path, 'status', "--long"] |
16 | | - p_status = subprocess.run(cmd_status, capture_output=True, text=True) |
| 19 | + p_status = subprocess.run(cmd_status, capture_output=True, cwd="test/data/status_data", text=True) |
17 | 20 |
|
18 | 21 | assert "Changes to be committed" in p_status.stdout |
19 | 22 | assert "new file" in p_status.stdout |
20 | 23 |
|
21 | 24 | cmd_commit = [git2cpp_path, 'commit', "-m", "test commit"] |
22 | | - subprocess.run(cmd_commit, capture_output=True, text=True) |
| 25 | + subprocess.run(cmd_commit, cwd="test/data/status_data", text=True) |
23 | 26 |
|
24 | 27 | cmd_status_2 = [git2cpp_path, 'status', "--long"] |
25 | | - p_status_2 = subprocess.run(cmd_status_2, capture_output=True, text=True) |
| 28 | + p_status_2 = subprocess.run(cmd_status_2, capture_output=True, cwd="test/data/status_data", text=True) |
26 | 29 |
|
27 | 30 | assert "mook_file" not in p_status_2.stdout |
28 | 31 |
|
29 | 32 | cmd_reset = [git2cpp_path, 'reset', "--hard", "HEAD~1"] |
30 | | - subprocess.run(cmd_reset, capture_output=True, text=True) |
| 33 | + subprocess.run(cmd_reset, cwd="test/data/status_data", text=True) |
| 34 | + |
| 35 | + checkout_cmd.remove('-b') |
| 36 | + checkout_cmd[2] = 'main' |
| 37 | + subprocess.run(checkout_cmd, cwd="test/data/status_data", text=True) |
| 38 | + |
| 39 | + del_cmd = [git2cpp_path, 'branch', '-d', 'foregone'] |
| 40 | + subprocess.run(del_cmd, cwd="test/data/status_data", text=True) |
0 commit comments