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 , 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 ('' )
1516
16- with open ( "./test/data/xtl/ CMakeLists.txt", "a" ) as f : # Changes not staged for commit / modified
17- f . write ("blablabla" )
17+ pw = xtl_path / " CMakeLists.txt" # Changes not staged for commit / modified
18+ pw . write_text ("blablabla" )
1819
19- os .remove ("./test/data/xtl/ README.md" ) # Changes not staged for commit / deleted
20+ os .remove (xtl_path / " README.md" ) # Changes not staged for commit / deleted
2021
2122 cmd = [git2cpp_path , 'status' ]
2223 if short_flag != "" :
2324 cmd .append (short_flag )
2425 if long_flag != "" :
2526 cmd .append (long_flag )
26- p = subprocess .run (cmd , capture_output = True , cwd = working_dir , text = True )
27- assert p .returncode == 0
27+ p = subprocess .run (cmd , capture_output = True , cwd = xtl_path , text = True )
2828
2929 if (long_flag == "--long" ) or ((long_flag == "" ) & (short_flag == "" )):
3030 assert "On branch master" in p .stdout
@@ -41,30 +41,34 @@ def test_status_new_file(xtl_clone, git2cpp_path, short_flag, long_flag):
4141
4242@pytest .mark .parametrize ("short_flag" , ["" , "-s" , "--short" ])
4343@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
44+ def test_status_add_file (xtl_clone , git2cpp_path , tmp_path , short_flag , long_flag ):
45+ assert ( tmp_path / "xtl" ). exists ()
46+ xtl_path = tmp_path / "xtl"
4747
48- os .remove ("./test/data/xtl/README.md" ) # Changes to be committed / deleted
48+ p = xtl_path / "mook_file.txt" # Changes to be committed / new file
49+ p .write_text ('' )
50+
51+ os .remove (xtl_path / "README.md" ) # Changes to be committed / deleted
4952
5053 cmd_add = [git2cpp_path , 'add' , "--all" ]
51- p = subprocess .run (cmd_add , cwd = working_dir , text = True )
52- assert p .returncode == 0
54+ p_add = subprocess .run (cmd_add , cwd = xtl_path , text = True )
55+ assert p_add .returncode == 0
5356
5457 cmd_status = [git2cpp_path , 'status' ]
5558 if short_flag != "" :
5659 cmd_status .append (short_flag )
5760 if long_flag != "" :
5861 cmd_status .append (long_flag )
59- p = subprocess .run (cmd_status , capture_output = True , cwd = working_dir , text = True )
62+ p_status = subprocess .run (cmd_status , capture_output = True , cwd = xtl_path , text = True )
63+ assert p_status .returncode == 0
6064
6165 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
66+ assert "Changes to be committed" in p_status .stdout
67+ assert "Changes not staged for commit" not in p_status .stdout
68+ assert "Untracked files" not in p_status .stdout
69+ assert "new file" in p_status .stdout
70+ assert "deleted" in p_status .stdout
6771
6872 elif short_flag in ["-s" , "--short" ]:
69- assert "A " in p .stdout
70- assert "D " in p .stdout
73+ assert "A " in p_status .stdout
74+ assert "D " in p_status .stdout
0 commit comments