From 37099098764ae7f308aafec19c4ea89c848eaa74 Mon Sep 17 00:00:00 2001 From: Joachim Jablon Date: Sun, 11 Jun 2023 15:07:56 +0200 Subject: [PATCH] fix test --- coverage_comment/subprocess.py | 4 ++-- tests/unit/test_subprocess.py | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/coverage_comment/subprocess.py b/coverage_comment/subprocess.py index b417f661..db4b7423 100644 --- a/coverage_comment/subprocess.py +++ b/coverage_comment/subprocess.py @@ -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 @@ -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, ) diff --git a/tests/unit/test_subprocess.py b/tests/unit/test_subprocess.py index 4c2d4aae..8d40c2b3 100644 --- a/tests/unit/test_subprocess.py +++ b/tests/unit/test_subprocess.py @@ -1,3 +1,5 @@ +import pathlib + import pytest from coverage_comment import subprocess @@ -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) @@ -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, + ), ] ) @@ -77,3 +85,4 @@ def test_git__error(mocker): with pytest.raises(subprocess.GitError): git.add("some_file") + git.add("some_file")