@@ -12,16 +12,28 @@ def test_empty_file(tmp_path):
1212 r = Repo .init (tmp_path )
1313 instance = util .Util (tmp_path )
1414 authors = instance .get_authors (path = file_name )
15- assert authors == ""
15+ assert authors == []
1616
1717 # Get authors of empty, committed file
1818 r .index .add ([file_name ])
1919 author = Actor (
'Tim' ,
'[email protected] ' )
2020 r .index .commit ("initial commit" , author = author )
2121 authors = instance .get_authors (path = file_name )
22- assert authors == ""
22+ assert authors == []
2323
2424def test_retrieve_authors (tmp_path ):
25+ """
26+ Builds a fake git project with some commits.
27+
28+ pytest offers a `tmp_path`. You can reproduce locally with
29+ >>> import tempfile
30+ >>> from pathlib import Path
31+ >>> tmp_path = Path(tempfile.gettempdir()) / 'pytest-retrieve-authors'
32+ >>> os.mkdir(tmp_path)
33+
34+ Args:
35+ tmp_path (PosixPath): Directory of a tempdir
36+ """
2537
2638 # Create file
2739 file_name = os .path .join (tmp_path , 'new-file' )
@@ -36,6 +48,7 @@ def test_retrieve_authors(tmp_path):
3648
3749 instance = util .Util (tmp_path )
3850 authors = instance .get_authors (path = file_name )
51+ # We don't want to test datetime
3952 authors [0 ]['last_datetime' ] = None
4053
4154 assert authors == [{
@@ -53,7 +66,8 @@ def test_retrieve_authors(tmp_path):
5366 r .index .add ([file_name ])
5467 author = Actor (
'Tim2' ,
'[email protected] ' )
5568 r .index .commit ("another commit" , author = author )
56-
69+
70+ instance = util .Util (tmp_path )
5771 authors = instance .get_authors (path = file_name )
5872 authors [0 ]['last_datetime' ] = None
5973
@@ -71,7 +85,8 @@ def test_retrieve_authors(tmp_path):
7185 r .index .add ([file_name ])
7286 author = Actor (
'John' ,
'[email protected] ' )
7387 r .index .commit ("third commit" , author = author )
74-
88+
89+ instance = util .Util (tmp_path )
7590 authors = instance .get_authors (path = file_name )
7691 authors [0 ]['last_datetime' ] = None
7792 authors [1 ]['last_datetime' ] = None
0 commit comments