66def test_checkout (repo_init_with_commit , git2cpp_path , tmp_path ):
77 assert (tmp_path / "initial.txt" ).exists ()
88
9- default_branch = subprocess .run (
10- ["git" , "branch" , "--show-current" ],
11- capture_output = True ,
12- cwd = tmp_path ,
13- text = True ,
14- check = True ,
15- ).stdout .strip () # TODO: use git2cpp when "branch --show-current" is implemented
16-
179 create_cmd = [git2cpp_path , "branch" , "foregone" ]
1810 p_create = subprocess .run (create_cmd , capture_output = True , cwd = tmp_path , text = True )
1911 assert p_create .returncode == 0
@@ -28,27 +20,19 @@ def test_checkout(repo_init_with_commit, git2cpp_path, tmp_path):
2820 branch_cmd = [git2cpp_path , "branch" ]
2921 p_branch = subprocess .run (branch_cmd , capture_output = True , cwd = tmp_path , text = True )
3022 assert p_branch .returncode == 0
31- assert p_branch .stdout == f "* foregone\n { default_branch } \n "
23+ assert p_branch .stdout == "* foregone\n main \n "
3224
33- checkout_cmd [2 ] = default_branch
25+ checkout_cmd [2 ] = "main"
3426 p_checkout2 = subprocess .run (
3527 checkout_cmd , capture_output = True , cwd = tmp_path , text = True
3628 )
3729 assert p_checkout2 .returncode == 0
38- assert f "Switched to branch '{ default_branch } '" in p_checkout2 .stdout
30+ assert "Switched to branch 'main '" in p_checkout2 .stdout
3931
4032
4133def test_checkout_b (repo_init_with_commit , git2cpp_path , tmp_path ):
4234 assert (tmp_path / "initial.txt" ).exists ()
4335
44- default_branch = subprocess .run (
45- ["git" , "branch" , "--show-current" ],
46- capture_output = True ,
47- cwd = tmp_path ,
48- text = True ,
49- check = True ,
50- ).stdout .strip () # TODO: use git2cpp when "branch --show-current" is implemented
51-
5236 checkout_cmd = [git2cpp_path , "checkout" , "-b" , "foregone" ]
5337 p_checkout = subprocess .run (
5438 checkout_cmd , capture_output = True , cwd = tmp_path , text = True
@@ -59,16 +43,16 @@ def test_checkout_b(repo_init_with_commit, git2cpp_path, tmp_path):
5943 branch_cmd = [git2cpp_path , "branch" ]
6044 p_branch = subprocess .run (branch_cmd , capture_output = True , cwd = tmp_path , text = True )
6145 assert p_branch .returncode == 0
62- assert p_branch .stdout == f "* foregone\n { default_branch } \n "
46+ assert p_branch .stdout == "* foregone\n main \n "
6347
6448 checkout_cmd .remove ("-b" )
65- checkout_cmd [2 ] = default_branch
49+ checkout_cmd [2 ] = "main"
6650 p_checkout2 = subprocess .run (checkout_cmd , cwd = tmp_path , text = True )
6751 assert p_checkout2 .returncode == 0
6852
6953 p_branch2 = subprocess .run (branch_cmd , capture_output = True , cwd = tmp_path , text = True )
7054 assert p_branch2 .returncode == 0
71- assert p_branch2 .stdout == f " foregone\n * { default_branch } \n "
55+ assert p_branch2 .stdout == " foregone\n * main \n "
7256
7357
7458def test_checkout_B_force_create (repo_init_with_commit , git2cpp_path , tmp_path ):
@@ -143,14 +127,6 @@ def test_checkout_refuses_overwrite(
143127 initial_file = tmp_path / "initial.txt"
144128 assert (initial_file ).exists ()
145129
146- default_branch = subprocess .run (
147- ["git" , "branch" , "--show-current" ],
148- capture_output = True ,
149- cwd = tmp_path ,
150- text = True ,
151- check = True ,
152- ).stdout .strip () # TODO: use git2cpp when "branch --show-current" is implemented
153-
154130 # Create a new branch and switch to it
155131 create_cmd = [git2cpp_path , "checkout" , "-b" , "newbranch" ]
156132 p_create = subprocess .run (create_cmd , capture_output = True , cwd = tmp_path , text = True )
@@ -166,14 +142,14 @@ def test_checkout_refuses_overwrite(
166142 subprocess .run (commit_cmd , cwd = tmp_path , text = True )
167143
168144 # Switch back to default branch
169- checkout_default_cmd = [git2cpp_path , "checkout" , default_branch ]
145+ checkout_default_cmd = [git2cpp_path , "checkout" , "main" ]
170146 p_default = subprocess .run (
171147 checkout_default_cmd , capture_output = True , cwd = tmp_path , text = True
172148 )
173149 assert p_default .returncode == 0
174150
175151 # Now modify initial.txt locally (unstaged) on default branch
176- initial_file .write_text (f "Local modification on { default_branch } " )
152+ initial_file .write_text ("Local modification on main " )
177153
178154 # Try to checkout newbranch
179155 checkout_cmd = [git2cpp_path , "checkout" ]
@@ -201,7 +177,7 @@ def test_checkout_refuses_overwrite(
201177 p_branch = subprocess .run (
202178 branch_cmd , capture_output = True , cwd = tmp_path , text = True
203179 )
204- assert f "* { default_branch } " in p_branch .stdout
180+ assert "* main " in p_branch .stdout
205181 else :
206182 assert "Switched to branch 'newbranch'" in p_checkout .stdout
207183
0 commit comments