|
3 | 3 | import pytest |
4 | 4 |
|
5 | 5 |
|
6 | | -def test_branch_list(xtl_clone, git2cpp_path, tmp_path): |
7 | | - assert (tmp_path / "xtl").exists() |
8 | | - xtl_path = tmp_path / "xtl" |
| 6 | +def test_branch_list(repo_init_with_commit, git2cpp_path, tmp_path): |
| 7 | + assert (tmp_path / "initial.txt").exists() |
9 | 8 |
|
10 | | - cmd = [git2cpp_path, 'branch'] |
11 | | - p = subprocess.run(cmd, capture_output=True, cwd=xtl_path, text=True) |
| 9 | + cmd = [git2cpp_path, "branch"] |
| 10 | + p = subprocess.run(cmd, capture_output=True, cwd=tmp_path, text=True) |
12 | 11 | assert p.returncode == 0 |
13 | | - assert(p.stdout == '* master\n') |
| 12 | + assert "* ma" in p.stdout |
14 | 13 |
|
15 | 14 |
|
16 | | -def test_branch_create_delete(xtl_clone, git2cpp_path, tmp_path): |
17 | | - assert (tmp_path / "xtl").exists() |
18 | | - xtl_path = tmp_path / "xtl" |
| 15 | +def test_branch_create_delete(repo_init_with_commit, git2cpp_path, tmp_path): |
| 16 | + assert (tmp_path / "initial.txt").exists() |
19 | 17 |
|
20 | | - create_cmd = [git2cpp_path, 'branch', 'foregone'] |
21 | | - p_create = subprocess.run(create_cmd, capture_output=True, cwd=xtl_path, text=True) |
| 18 | + create_cmd = [git2cpp_path, "branch", "foregone"] |
| 19 | + p_create = subprocess.run(create_cmd, capture_output=True, cwd=tmp_path, text=True) |
22 | 20 | assert p_create.returncode == 0 |
23 | 21 |
|
24 | | - list_cmd = [git2cpp_path, 'branch'] |
25 | | - p_list = subprocess.run(list_cmd, capture_output=True, cwd=xtl_path, text=True) |
| 22 | + list_cmd = [git2cpp_path, "branch"] |
| 23 | + p_list = subprocess.run(list_cmd, capture_output=True, cwd=tmp_path, text=True) |
26 | 24 | assert p_list.returncode == 0 |
27 | | - assert(p_list.stdout == ' foregone\n* master\n') |
| 25 | + assert " foregone\n* ma" in p_list.stdout |
28 | 26 |
|
29 | | - del_cmd = [git2cpp_path, 'branch', '-d', 'foregone'] |
30 | | - p_del = subprocess.run(del_cmd, capture_output=True, cwd=xtl_path, text=True) |
| 27 | + del_cmd = [git2cpp_path, "branch", "-d", "foregone"] |
| 28 | + p_del = subprocess.run(del_cmd, capture_output=True, cwd=tmp_path, text=True) |
31 | 29 | assert p_del.returncode == 0 |
32 | 30 |
|
33 | | - p_list2 = subprocess.run(list_cmd, capture_output=True, cwd=xtl_path, text=True) |
| 31 | + p_list2 = subprocess.run(list_cmd, capture_output=True, cwd=tmp_path, text=True) |
34 | 32 | assert p_list2.returncode == 0 |
35 | | - assert(p_list2.stdout == '* master\n') |
| 33 | + assert "* ma" in p_list2.stdout |
| 34 | + |
36 | 35 |
|
37 | 36 | def test_branch_nogit(git2cpp_path, tmp_path): |
38 | | - cmd = [git2cpp_path, 'branch'] |
| 37 | + cmd = [git2cpp_path, "branch"] |
39 | 38 | p = subprocess.run(cmd, capture_output=True, cwd=tmp_path, text=True) |
40 | 39 | assert p.returncode != 0 |
41 | 40 | assert "error: could not find repository at" in p.stderr |
42 | 41 |
|
43 | 42 |
|
44 | 43 | def test_branch_new_repo(git2cpp_path, tmp_path, run_in_tmp_path): |
45 | | - # tmp_path exists and is empty. |
| 44 | + # tmp_path exists and is empty. |
46 | 45 | assert list(tmp_path.iterdir()) == [] |
47 | 46 |
|
48 | | - cmd = [git2cpp_path, 'init'] |
49 | | - p = subprocess.run(cmd, cwd = tmp_path) |
| 47 | + cmd = [git2cpp_path, "init"] |
| 48 | + subprocess.run(cmd, cwd=tmp_path, check=True) |
50 | 49 |
|
51 | | - branch_cmd = [git2cpp_path, 'branch'] |
52 | | - p_branch = subprocess.run(branch_cmd, cwd = tmp_path) |
| 50 | + branch_cmd = [git2cpp_path, "branch"] |
| 51 | + p_branch = subprocess.run(branch_cmd, cwd=tmp_path) |
53 | 52 |
|
54 | 53 | assert p_branch.returncode == 0 |
0 commit comments