-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest_checkout.py
More file actions
50 lines (37 loc) · 1.85 KB
/
test_checkout.py
File metadata and controls
50 lines (37 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import subprocess
import pytest
def test_checkout(xtl_clone, git2cpp_path, tmp_path):
assert (tmp_path / "xtl").exists()
xtl_path = tmp_path / "xtl"
create_cmd = [git2cpp_path, 'branch', 'foregone']
p_create = subprocess.run(create_cmd, capture_output=True, cwd=xtl_path, text=True)
assert p_create.returncode == 0
checkout_cmd = [git2cpp_path, 'checkout', 'foregone']
p_checkout = subprocess.run(checkout_cmd, capture_output=True, cwd=xtl_path, text=True)
assert p_checkout.returncode == 0
assert(p_checkout.stdout == '');
branch_cmd = [git2cpp_path, 'branch']
p_branch = subprocess.run(branch_cmd, capture_output=True, cwd=xtl_path, text=True)
assert p_branch.returncode == 0
assert(p_branch.stdout == '* foregone\n master\n')
checkout_cmd[2] = 'master'
p_checkout2 = subprocess.run(checkout_cmd, capture_output=True, cwd=xtl_path, text=True)
assert p_checkout2.returncode == 0
def test_checkout_b(xtl_clone, git2cpp_path, tmp_path):
assert (tmp_path / "xtl").exists()
xtl_path = tmp_path / "xtl"
checkout_cmd = [git2cpp_path, 'checkout', '-b', 'foregone']
p_checkout = subprocess.run(checkout_cmd, capture_output=True, cwd=xtl_path, text=True)
assert p_checkout.returncode == 0
assert(p_checkout.stdout == '');
branch_cmd = [git2cpp_path, 'branch']
p_branch = subprocess.run(branch_cmd, capture_output=True, cwd=xtl_path, text=True)
assert p_branch.returncode == 0
assert(p_branch.stdout == '* foregone\n master\n')
checkout_cmd.remove('-b')
checkout_cmd[2] = 'master'
p_checkout2 = subprocess.run(checkout_cmd, cwd=xtl_path, text=True)
assert p_checkout2.returncode == 0
p_branch2 = subprocess.run(branch_cmd, capture_output=True, cwd=xtl_path, text=True)
assert p_branch2.returncode == 0
assert(p_branch2.stdout == ' foregone\n* master\n')