Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
ewjoachim committed Jun 11, 2023
1 parent d2c21df commit 3709909
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions coverage_comment/subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Git:
>>> git.rev_parse("--short", "HEAD")
"""

cwd = "."
cwd = pathlib.Path(".")

def _git(self, *args: str, env: dict[str, str] | None = None, **kwargs) -> str:
# When setting the `env` argument to run, instead of inheriting env
Expand All @@ -56,7 +56,7 @@ def _git(self, *args: str, env: dict[str, str] | None = None, **kwargs) -> str:
return run(
"git",
*args,
cwd=self.cwd,
path=self.cwd,
env=os.environ | (env or {}),
**kwargs,
)
Expand Down
15 changes: 12 additions & 3 deletions tests/unit/test_subprocess.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import pathlib

import pytest

from coverage_comment import subprocess
Expand Down Expand Up @@ -28,7 +30,7 @@ def environ(mocker):
def test_git(mocker, environ):
run = mocker.patch("coverage_comment.subprocess.run")
git = subprocess.Git()
git.cwd = "/tmp"
git.cwd = pathlib.Path("/tmp")
environ["A"] = "B"

git.clone("https://some_address.git", "--depth", "1", text=True)
Expand All @@ -42,11 +44,17 @@ def test_git(mocker, environ):
"https://some_address.git",
"--depth",
"1",
cwd="/tmp",
path=pathlib.Path("/tmp"),
text=True,
env=mocker.ANY,
),
mocker.call("git", "add", "some_file", cwd="/tmp", env=mocker.ANY),
mocker.call(
"git",
"add",
"some_file",
path=pathlib.Path("/tmp"),
env=mocker.ANY,
),
]
)

Expand Down Expand Up @@ -77,3 +85,4 @@ def test_git__error(mocker):

with pytest.raises(subprocess.GitError):
git.add("some_file")
git.add("some_file")

0 comments on commit 3709909

Please sign in to comment.