55import pytest
66
77
8- working_dir = 'test/data/xtl'
9-
108@pytest .mark .parametrize ("short_flag" , ["" , "-s" , "--short" ])
119@pytest .mark .parametrize ("long_flag" , ["" , "--long" ])
12- def test_status_new_file (xtl_clone , git2cpp_path , short_flag , long_flag ):
13- with open ( "./test/data/ xtl/mook_file.txt", "x" ): # Untracked files
14- pass
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 ( '' )
1513
16- with open ( "./test/data/ xtl/CMakeLists.txt", "a" ) as f : # Changes not staged for commit / modified
17- f .write ("blablabla" )
14+ fw = tmp_path / " xtl/CMakeLists.txt" # Changes not staged for commit / modified
15+ fw .write ("blablabla" )
1816
19- os .remove ("./test/data/ xtl/README.md" ) # Changes not staged for commit / deleted
17+ os .remove (tmp_path / " xtl/README.md" ) # Changes not staged for commit / deleted
2018
2119 cmd = [git2cpp_path , 'status' ]
2220 if short_flag != "" :
2321 cmd .append (short_flag )
2422 if long_flag != "" :
2523 cmd .append (long_flag )
26- p = subprocess .run (cmd , capture_output = True , cwd = working_dir , text = True )
27- assert p .returncode == 0
24+ p = subprocess .run (cmd , capture_output = True , cwd = tmp_path , text = True )
2825
2926 if (long_flag == "--long" ) or ((long_flag == "" ) & (short_flag == "" )):
3027 assert "On branch master" in p .stdout
@@ -41,30 +38,34 @@ def test_status_new_file(xtl_clone, git2cpp_path, short_flag, long_flag):
4138
4239@pytest .mark .parametrize ("short_flag" , ["" , "-s" , "--short" ])
4340@pytest .mark .parametrize ("long_flag" , ["" , "--long" ])
44- def test_status_add_file (xtl_clone , git2cpp_path , short_flag , long_flag ):
45- with open ("./test/data/xtl/mook_file.txt" , "x" ): # Changes to be committed / new file
46- pass
41+ def test_status_add_file (xtl_clone , git2cpp_path , tmp_path , run_in_tmp_path , short_flag , long_flag ):
42+ assert (tmp_path / "xtl" ).exists ()
43+ xtl_path = tmp_path / "xtl"
44+
45+ p = xtl_path / "mook_file.txt" # Changes to be committed / new file
46+ p .write_text ('' )
4747
48- os .remove ("./test/data/xtl/ README.md" ) # Changes to be committed / deleted
48+ os .remove (xtl_path / " README.md" ) # Changes to be committed / deleted
4949
5050 cmd_add = [git2cpp_path , 'add' , "--all" ]
51- p = subprocess .run (cmd_add , cwd = working_dir , text = True )
52- assert p .returncode == 0
51+ p_add = subprocess .run (cmd_add , cwd = xtl_path , text = True )
52+ assert p_add .returncode == 0
5353
5454 cmd_status = [git2cpp_path , 'status' ]
5555 if short_flag != "" :
5656 cmd_status .append (short_flag )
5757 if long_flag != "" :
5858 cmd_status .append (long_flag )
59- p = subprocess .run (cmd_status , capture_output = True , cwd = working_dir , text = True )
59+ p_status = subprocess .run (cmd_status , capture_output = True , cwd = xtl_path , text = True )
60+ assert p_status .returncode == 0
6061
6162 if (long_flag == "--long" ) or ((long_flag == "" ) & (short_flag == "" )):
62- assert "Changes to be committed" in p .stdout
63- assert "Changes not staged for commit" not in p .stdout
64- assert "Untracked files" not in p .stdout
65- assert "new file" in p .stdout
66- assert "deleted" in p .stdout
63+ assert "Changes to be committed" in p_status .stdout
64+ assert "Changes not staged for commit" not in p_status .stdout
65+ assert "Untracked files" not in p_status .stdout
66+ assert "new file" in p_status .stdout
67+ assert "deleted" in p_status .stdout
6768
6869 elif short_flag in ["-s" , "--short" ]:
69- assert "A " in p .stdout
70- assert "D " in p .stdout
70+ assert "A " in p_status .stdout
71+ assert "D " in p_status .stdout
0 commit comments