1
1
"""Tests for libvcs git repos."""
2
2
import datetime
3
3
import os
4
+ import pathlib
4
5
import textwrap
5
6
6
7
import pytest
14
15
pytestmark = pytest .mark .skip (reason = "git is not available" )
15
16
16
17
17
- def test_repo_git_obtain_initial_commit_repo (tmpdir ):
18
+ def test_repo_git_obtain_initial_commit_repo (tmp_path : pathlib . Path ):
18
19
"""initial commit repos return 'initial'.
19
20
20
21
note: this behaviors differently from git(1)'s use of the word "bare".
21
22
running `git rev-parse --is-bare-repository` would return false.
22
23
"""
23
24
repo_name = "my_git_project"
24
25
25
- run (["git" , "init" , repo_name ], cwd = str (tmpdir ))
26
+ run (["git" , "init" , repo_name ], cwd = str (tmp_path ))
26
27
27
- bare_repo_dir = tmpdir . join ( repo_name )
28
+ bare_repo_dir = tmp_path / repo_name
28
29
29
30
git_repo = create_repo_from_pip_url (
30
31
** {
31
32
"pip_url" : "git+file://" + str (bare_repo_dir ),
32
- "repo_dir" : str (tmpdir . join ( "obtaining a bare repo" ) ),
33
+ "repo_dir" : str (tmp_path / "obtaining a bare repo" ),
33
34
}
34
35
)
35
36
36
37
git_repo .obtain ()
37
38
assert git_repo .get_revision () == "initial"
38
39
39
40
40
- def test_repo_git_obtain_full (tmpdir , git_remote ):
41
+ def test_repo_git_obtain_full (tmp_path : pathlib . Path , git_remote ):
41
42
git_repo = create_repo_from_pip_url (
42
43
** {
43
44
"pip_url" : "git+file://" + git_remote ,
44
- "repo_dir" : str (tmpdir . join ( "myrepo" ) ),
45
+ "repo_dir" : str (tmp_path / "myrepo" ),
45
46
}
46
47
)
47
48
@@ -50,14 +51,14 @@ def test_repo_git_obtain_full(tmpdir, git_remote):
50
51
test_repo_revision = run (["git" , "rev-parse" , "HEAD" ], cwd = git_remote )
51
52
52
53
assert git_repo .get_revision () == test_repo_revision
53
- assert os .path .exists (str (tmpdir . join ( "myrepo" ) ))
54
+ assert os .path .exists (str (tmp_path / "myrepo" ))
54
55
55
56
56
- def test_repo_update_handle_cases (tmpdir , git_remote , mocker ):
57
+ def test_repo_update_handle_cases (tmp_path : pathlib . Path , git_remote , mocker ):
57
58
git_repo = create_repo_from_pip_url (
58
59
** {
59
60
"pip_url" : "git+file://" + git_remote ,
60
- "repo_dir" : str (tmpdir . join ( "myrepo" ) ),
61
+ "repo_dir" : str (tmp_path / "myrepo" ),
61
62
}
62
63
)
63
64
@@ -75,7 +76,7 @@ def test_repo_update_handle_cases(tmpdir, git_remote, mocker):
75
76
assert mocker .call (["symbolic-ref" , "--short" , "HEAD" ]) not in mocka .mock_calls
76
77
77
78
78
- def test_progress_callback (tmpdir , git_remote , mocker ):
79
+ def test_progress_callback (tmp_path : pathlib . Path , git_remote , mocker ):
79
80
def progress_callback_spy (output , timestamp ):
80
81
assert isinstance (output , str )
81
82
assert isinstance (timestamp , datetime .datetime )
@@ -90,7 +91,7 @@ def progress_callback_spy(output, timestamp):
90
91
git_repo = create_repo_from_pip_url (
91
92
** {
92
93
"pip_url" : "git+file://" + git_remote ,
93
- "repo_dir" : str (tmpdir . join ( "myrepo" ) ),
94
+ "repo_dir" : str (tmp_path / "myrepo" ),
94
95
"progress_callback" : progress_callback ,
95
96
}
96
97
)
0 commit comments