1- from pathlib import Path
21import subprocess
2+ from pathlib import Path
33
44
55def test_init_in_directory (git2cpp_path , tmp_path ):
66 # tmp_path exists and is empty.
77 assert list (tmp_path .iterdir ()) == []
88
9- cmd = [git2cpp_path , ' init' , ' --bare' , str (tmp_path )]
9+ cmd = [git2cpp_path , " init" , " --bare" , str (tmp_path )]
1010 p = subprocess .run (cmd , capture_output = True )
1111 assert p .returncode == 0
12- assert p .stdout == b''
13- assert p .stderr == b''
12+ assert p .stdout == b""
13+ assert p .stderr == b""
1414
1515 assert sorted (map (lambda path : path .name , tmp_path .iterdir ())) == [
16- 'HEAD' , 'config' , 'description' , 'hooks' , 'info' , 'objects' , 'refs'
16+ "HEAD" ,
17+ "config" ,
18+ "description" ,
19+ "hooks" ,
20+ "info" ,
21+ "objects" ,
22+ "refs" ,
1723 ]
1824
1925 # TODO: check this is a valid git repo
@@ -24,14 +30,20 @@ def test_init_in_cwd(git2cpp_path, tmp_path, run_in_tmp_path):
2430 assert list (tmp_path .iterdir ()) == []
2531 assert Path .cwd () == tmp_path
2632
27- cmd = [git2cpp_path , ' init' , ' --bare' ]
33+ cmd = [git2cpp_path , " init" , " --bare" ]
2834 p = subprocess .run (cmd , capture_output = True )
2935 assert p .returncode == 0
30- assert p .stdout == b''
31- assert p .stderr == b''
36+ assert p .stdout == b""
37+ assert p .stderr == b""
3238
3339 assert sorted (map (lambda path : path .name , tmp_path .iterdir ())) == [
34- 'HEAD' , 'config' , 'description' , 'hooks' , 'info' , 'objects' , 'refs'
40+ "HEAD" ,
41+ "config" ,
42+ "description" ,
43+ "hooks" ,
44+ "info" ,
45+ "objects" ,
46+ "refs" ,
3547 ]
3648
3749 # TODO: check this is a valid git repo
@@ -41,38 +53,43 @@ def test_init_not_bare(git2cpp_path, tmp_path):
4153 # tmp_path exists and is empty.
4254 assert list (tmp_path .iterdir ()) == []
4355
44- cmd = [git2cpp_path , ' init' , '.' ]
56+ cmd = [git2cpp_path , " init" , "." ]
4557 p = subprocess .run (cmd , capture_output = True , cwd = tmp_path )
4658 assert p .returncode == 0
47- assert p .stdout == b''
48- assert p .stderr == b''
59+ assert p .stdout == b""
60+ assert p .stderr == b""
4961
50- # Directory contains just .git directory.
51- assert sorted (map (lambda path : path .name , tmp_path .iterdir ())) == [' .git' ]
62+ # Directory contains just .git directory.
63+ assert sorted (map (lambda path : path .name , tmp_path .iterdir ())) == [" .git" ]
5264 # .git directory is a valid repo.
53- assert sorted (map (lambda path : path .name , (tmp_path / '.git' ).iterdir ())) == [
54- 'HEAD' , 'config' , 'description' , 'hooks' , 'info' , 'objects' , 'refs'
65+ assert sorted (map (lambda path : path .name , (tmp_path / ".git" ).iterdir ())) == [
66+ "HEAD" ,
67+ "config" ,
68+ "description" ,
69+ "hooks" ,
70+ "info" ,
71+ "objects" ,
72+ "refs" ,
5573 ]
5674
5775 # Would like to use `git2cpp status` but it complains that 'refs/heads/master' not found
58- cmd = [git2cpp_path , ' log' ]
76+ cmd = [git2cpp_path , " log" ]
5977 p = subprocess .run (cmd , capture_output = True , cwd = tmp_path )
6078 assert p .returncode == 0
61- assert p .stdout == b''
62- assert p .stderr == b''
79+ assert b"does not have any commits yet" in p .stdout
6380
6481
6582def test_error_on_unknown_option (git2cpp_path ):
66- cmd = [git2cpp_path , ' init' , ' --unknown' ]
83+ cmd = [git2cpp_path , " init" , " --unknown" ]
6784 p = subprocess .run (cmd , capture_output = True )
6885 assert p .returncode == 109
69- assert p .stdout == b''
86+ assert p .stdout == b""
7087 assert p .stderr .startswith (b"The following argument was not expected: --unknown" )
7188
7289
7390def test_error_on_repeated_directory (git2cpp_path ):
74- cmd = [git2cpp_path , ' init' , ' abc' , ' def' ]
91+ cmd = [git2cpp_path , " init" , " abc" , " def" ]
7592 p = subprocess .run (cmd , capture_output = True )
7693 assert p .returncode == 109
77- assert p .stdout == b''
94+ assert p .stdout == b""
7895 assert p .stderr .startswith (b"The following argument was not expected: def" )
0 commit comments