Skip to content

Commit 806c69c

Browse files
committed
refactor(test_git): tmpdir -> tmp_path (pathlib.Path)
1 parent 7089fbc commit 806c69c

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

tests/test_git.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Tests for libvcs git repos."""
22
import datetime
33
import os
4+
import pathlib
45
import textwrap
56

67
import pytest
@@ -14,34 +15,34 @@
1415
pytestmark = pytest.mark.skip(reason="git is not available")
1516

1617

17-
def test_repo_git_obtain_initial_commit_repo(tmpdir):
18+
def test_repo_git_obtain_initial_commit_repo(tmp_path: pathlib.Path):
1819
"""initial commit repos return 'initial'.
1920
2021
note: this behaviors differently from git(1)'s use of the word "bare".
2122
running `git rev-parse --is-bare-repository` would return false.
2223
"""
2324
repo_name = "my_git_project"
2425

25-
run(["git", "init", repo_name], cwd=str(tmpdir))
26+
run(["git", "init", repo_name], cwd=str(tmp_path))
2627

27-
bare_repo_dir = tmpdir.join(repo_name)
28+
bare_repo_dir = tmp_path / repo_name
2829

2930
git_repo = create_repo_from_pip_url(
3031
**{
3132
"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"),
3334
}
3435
)
3536

3637
git_repo.obtain()
3738
assert git_repo.get_revision() == "initial"
3839

3940

40-
def test_repo_git_obtain_full(tmpdir, git_remote):
41+
def test_repo_git_obtain_full(tmp_path: pathlib.Path, git_remote):
4142
git_repo = create_repo_from_pip_url(
4243
**{
4344
"pip_url": "git+file://" + git_remote,
44-
"repo_dir": str(tmpdir.join("myrepo")),
45+
"repo_dir": str(tmp_path / "myrepo"),
4546
}
4647
)
4748

@@ -50,14 +51,14 @@ def test_repo_git_obtain_full(tmpdir, git_remote):
5051
test_repo_revision = run(["git", "rev-parse", "HEAD"], cwd=git_remote)
5152

5253
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"))
5455

5556

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):
5758
git_repo = create_repo_from_pip_url(
5859
**{
5960
"pip_url": "git+file://" + git_remote,
60-
"repo_dir": str(tmpdir.join("myrepo")),
61+
"repo_dir": str(tmp_path / "myrepo"),
6162
}
6263
)
6364

@@ -75,7 +76,7 @@ def test_repo_update_handle_cases(tmpdir, git_remote, mocker):
7576
assert mocker.call(["symbolic-ref", "--short", "HEAD"]) not in mocka.mock_calls
7677

7778

78-
def test_progress_callback(tmpdir, git_remote, mocker):
79+
def test_progress_callback(tmp_path: pathlib.Path, git_remote, mocker):
7980
def progress_callback_spy(output, timestamp):
8081
assert isinstance(output, str)
8182
assert isinstance(timestamp, datetime.datetime)
@@ -90,7 +91,7 @@ def progress_callback_spy(output, timestamp):
9091
git_repo = create_repo_from_pip_url(
9192
**{
9293
"pip_url": "git+file://" + git_remote,
93-
"repo_dir": str(tmpdir.join("myrepo")),
94+
"repo_dir": str(tmp_path / "myrepo"),
9495
"progress_callback": progress_callback,
9596
}
9697
)

0 commit comments

Comments
 (0)