1- import os
21from pathlib import Path
3- import pytest
42import subprocess
53
64
7- # Fixture to run test in current tmp_path
8- @pytest .fixture
9- def run_in_tmp_path (tmp_path ):
10- original_cwd = os .getcwd ()
11- os .chdir (tmp_path )
12- yield
13- os .chdir (original_cwd )
14-
15-
16- def test_init_in_directory (tmp_path ):
5+ def test_init_in_directory (git2cpp_path , tmp_path ):
176 # tmp_path exists and is empty.
187 assert list (tmp_path .iterdir ()) == []
198
20- cmd = ['/Users/iant/github/git2cpp/build/git2cpp' , 'init' , '--bare' , str (tmp_path )]
9+ cmd = [git2cpp_path , 'init' , '--bare' , str (tmp_path )]
2110 p = subprocess .run (cmd , capture_output = True )
2211 assert p .returncode == 0
2312 assert p .stdout == b''
@@ -30,12 +19,12 @@ def test_init_in_directory(tmp_path):
3019 # TODO: check this is a valid git repo
3120
3221
33- def test_init_in_cwd (tmp_path , run_in_tmp_path ):
22+ def test_init_in_cwd (git2cpp_path , tmp_path , run_in_tmp_path ):
3423 # tmp_path exists and is empty.
3524 assert list (tmp_path .iterdir ()) == []
3625 assert Path .cwd () == tmp_path
3726
38- cmd = ['/Users/iant/github/git2cpp/build/git2cpp' , 'init' , '--bare' ]
27+ cmd = [git2cpp_path , 'init' , '--bare' ]
3928 p = subprocess .run (cmd , capture_output = True )
4029 assert p .returncode == 0
4130 assert p .stdout == b''
@@ -51,16 +40,16 @@ def test_init_in_cwd(tmp_path, run_in_tmp_path):
5140# TODO: Test without bare flag.
5241
5342
54- def test_error_on_unknown_option ():
55- cmd = ['build/git2cpp' , 'init' , '--unknown' ]
43+ def test_error_on_unknown_option (git2cpp_path ):
44+ cmd = [git2cpp_path , 'init' , '--unknown' ]
5645 p = subprocess .run (cmd , capture_output = True )
5746 assert p .returncode == 1
5847 assert p .stdout == b''
5948 assert p .stderr .startswith (b"The following argument was not expected: --unknown" )
6049
6150
62- def test_error_on_repeated_directory ():
63- cmd = ['build/git2cpp' , 'init' , 'abc' , 'def' ]
51+ def test_error_on_repeated_directory (git2cpp_path ):
52+ cmd = [git2cpp_path , 'init' , 'abc' , 'def' ]
6453 p = subprocess .run (cmd , capture_output = True )
6554 assert p .returncode == 1
6655 assert p .stdout == b''
0 commit comments