Skip to content

Commit 72f2b65

Browse files
committed
fix path issue
1 parent 775749b commit 72f2b65

File tree

4 files changed

+46
-25
lines changed

4 files changed

+46
-25
lines changed

test/test_branch.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,33 @@
55

66

77
def test_branch_list(xtl_clone, git2cpp_path, tmp_path, run_in_tmp_path):
8+
assert (tmp_path / "xtl").exists()
9+
xtl_path = tmp_path / "xtl"
10+
811
cmd = [git2cpp_path, 'branch']
9-
p = subprocess.run(cmd, capture_output=True, cwd=tmp_path, text=True)
12+
p = subprocess.run(cmd, capture_output=True, cwd=xtl_path, text=True)
1013
assert p.returncode == 0
1114
assert(p.stdout == '* master\n')
1215

1316

1417
def test_branch_create_delete(xtl_clone, git2cpp_path, tmp_path, run_in_tmp_path):
18+
assert (tmp_path / "xtl").exists()
19+
xtl_path = tmp_path / "xtl"
20+
1521
create_cmd = [git2cpp_path, 'branch', 'foregone']
16-
p_create = subprocess.run(create_cmd, capture_output=True, cwd=tmp_path, text=True)
22+
p_create = subprocess.run(create_cmd, capture_output=True, cwd=xtl_path, text=True)
1723
assert p_create.returncode == 0
1824

1925
list_cmd = [git2cpp_path, 'branch']
20-
p_list = subprocess.run(list_cmd, capture_output=True, cwd=tmp_path, text=True)
26+
p_list = subprocess.run(list_cmd, capture_output=True, cwd=xtl_path, text=True)
2127
assert p_list.returncode == 0
2228
assert(p_list.stdout == ' foregone\n* master\n')
2329

30+
# Problem of right for "delete"? Maybe need a -D instead of -d
2431
del_cmd = [git2cpp_path, 'branch', '-d', 'foregone']
25-
subprocess.run(del_cmd, capture_output=True, cwd=tmp_path, text=True)
26-
p_list2 = subprocess.run(list_cmd, capture_output=True, cwd=tmp_path, text=True)
32+
p_del = subprocess.run(del_cmd, capture_output=True, cwd=tmp_path, text=True)
33+
assert p_del.returncode == 0
34+
35+
p_list2 = subprocess.run(list_cmd, capture_output=True, cwd=xtl_path, text=True)
2736
assert p_list2.returncode == 0
2837
assert(p_list2.stdout == '* master\n')

test/test_checkout.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,43 @@
55

66

77
def test_checkout(xtl_clone, git2cpp_path, tmp_path, run_in_tmp_path):
8+
assert (tmp_path / "xtl").exists()
9+
xtl_path = tmp_path / "xtl"
10+
811
create_cmd = [git2cpp_path, 'branch', 'foregone']
9-
p_create = subprocess.run(create_cmd, capture_output=True, cwd=tmp_path, text=True)
12+
p_create = subprocess.run(create_cmd, capture_output=True, cwd=xtl_path, text=True)
1013
assert p_create.returncode == 0
1114

1215
checkout_cmd = [git2cpp_path, 'checkout', 'foregone']
13-
p_checkout = subprocess.run(checkout_cmd, capture_output=True, cwd=tmp_path, text=True)
16+
p_checkout = subprocess.run(checkout_cmd, capture_output=True, cwd=xtl_path, text=True)
1417
assert p_checkout.returncode == 0
1518
assert(p_checkout.stdout == '');
1619

1720
branch_cmd = [git2cpp_path, 'branch']
18-
p_branch = subprocess.run(branch_cmd, capture_output=True, cwd=tmp_path, text=True)
21+
p_branch = subprocess.run(branch_cmd, capture_output=True, cwd=xtl_path, text=True)
1922
assert p_branch.returncode == 0
2023
assert(p_branch.stdout == '* foregone\n master\n')
2124

2225
checkout_cmd[2] = 'master'
23-
p_checkout2 = subprocess.run(checkout_cmd, capture_output=True, cwd=tmp_path, text=True)
26+
p_checkout2 = subprocess.run(checkout_cmd, capture_output=True, cwd=xtl_path, text=True)
2427
assert p_checkout2.returncode == 0
2528

2629

2730
def test_checkout_b(xtl_clone, git2cpp_path, tmp_path, run_in_tmp_path):
31+
assert (tmp_path / "xtl").exists()
32+
xtl_path = tmp_path / "xtl"
33+
2834
checkout_cmd = [git2cpp_path, 'checkout', '-b', 'foregone']
29-
p_checkout = subprocess.run(checkout_cmd, capture_output=True, cwd=tmp_path, text=True)
35+
p_checkout = subprocess.run(checkout_cmd, capture_output=True, cwd=xtl_path, text=True)
3036
assert p_checkout.returncode == 0
3137
assert(p_checkout.stdout == '');
3238

3339
branch_cmd = [git2cpp_path, 'branch']
34-
p_branch = subprocess.run(branch_cmd, capture_output=True, cwd=tmp_path, text=True)
40+
p_branch = subprocess.run(branch_cmd, capture_output=True, cwd=xtl_path, text=True)
3541
assert p_branch.returncode == 0
3642
assert(p_branch.stdout == '* foregone\n master\n')
3743

3844
checkout_cmd.remove('-b')
3945
checkout_cmd[2] = 'master'
40-
p_checkout2 = subprocess.run(checkout_cmd, cwd=tmp_path, text=True)
46+
p_checkout2 = subprocess.run(checkout_cmd, cwd=xtl_path, text=True)
4147
assert p_checkout2.returncode == 0

test/test_commit.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,28 @@
66

77
@pytest.mark.parametrize("all_flag", ["", "-A", "--all", "--no-ignore-removal"])
88
def test_commit(xtl_clone, git_config, git2cpp_path, tmp_path, run_in_tmp_path, tmp_path_factory, monkeypatch, all_flag):
9-
f = tmp_path / "xtl/mook_file.txt"
10-
f.write_text('')
9+
assert (tmp_path / "xtl").exists()
10+
xtl_path = tmp_path / "xtl"
11+
12+
p = xtl_path / "mook_file.txt"
13+
p.write_text('')
1114

1215
cmd_add = [git2cpp_path, 'add', "mook_file.txt"]
13-
p_add = subprocess.run(cmd_add, cwd=tmp_path, text=True)
16+
p_add = subprocess.run(cmd_add, cwd=xtl_path, text=True)
1417
assert p_add.returncode == 0
1518

1619
cmd_status = [git2cpp_path, 'status', "--long"]
17-
p_status = subprocess.run(cmd_status, capture_output=True, cwd=tmp_path, text=True)
20+
p_status = subprocess.run(cmd_status, capture_output=True, cwd=xtl_path, text=True)
1821
assert p_status.returncode == 0
1922

2023
assert "Changes to be committed" in p_status.stdout
2124
assert "new file" in p_status.stdout
2225

2326
cmd_commit = [git2cpp_path, 'commit', "-m", "test commit"]
24-
p_commit = subprocess.run(cmd_commit, cwd=tmp_path, text=True)
27+
p_commit = subprocess.run(cmd_commit, cwd=xtl_path, text=True)
2528
assert p_commit.returncode == 0
2629

2730
cmd_status_2 = [git2cpp_path, 'status', "--long"]
28-
p_status_2 = subprocess.run(cmd_status_2, capture_output=True, cwd=tmp_path, text=True)
31+
p_status_2 = subprocess.run(cmd_status_2, capture_output=True, cwd=xtl_path, text=True)
2932
assert p_status_2.returncode == 0
3033
assert "mook_file" not in p_status_2.stdout

test/test_status.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,24 @@
77

88
@pytest.mark.parametrize("short_flag", ["", "-s", "--short"])
99
@pytest.mark.parametrize("long_flag", ["", "--long"])
10-
def test_status_new_file(xtl_clone, git2cpp_path, tmp_path, run_in_tmp_path, tmp_path_factory, short_flag, long_flag):
11-
f = tmp_path / "xtl/mook_file.txt" # Untracked files
12-
f.write_text('')
10+
def test_status_new_file(xtl_clone, git2cpp_path, tmp_path, run_in_tmp_path, short_flag, long_flag):
11+
assert (tmp_path / "xtl").exists()
12+
xtl_path = tmp_path / "xtl"
13+
14+
p = xtl_path / "mook_file.txt" # Untracked files
15+
p.write_text('')
1316

14-
fw = tmp_path / "xtl/CMakeLists.txt" # Changes not staged for commit / modified
15-
fw.write("blablabla")
17+
pw = xtl_path / "CMakeLists.txt" # Changes not staged for commit / modified
18+
pw.write_text("blablabla")
1619

17-
os.remove(tmp_path / "xtl/README.md") # Changes not staged for commit / deleted
20+
os.remove(xtl_path / "README.md") # Changes not staged for commit / deleted
1821

1922
cmd = [git2cpp_path, 'status']
2023
if short_flag != "":
2124
cmd.append(short_flag)
2225
if long_flag != "":
2326
cmd.append(long_flag)
24-
p = subprocess.run(cmd, capture_output=True, cwd=tmp_path, text=True)
27+
p = subprocess.run(cmd, capture_output=True, cwd=xtl_path, text=True)
2528

2629
if (long_flag == "--long") or ((long_flag == "") & (short_flag == "")):
2730
assert "On branch master" in p.stdout

0 commit comments

Comments
 (0)