Skip to content

Commit

Permalink
Merge pull request #822 from TeoZosa/test/reproduce-previous-error-in…
Browse files Browse the repository at this point in the history
…-test-which-infers-git-repo-root-with-bad-ownership

✅ Validate previous method to infer git repo root directory throws the expected error
  • Loading branch information
TeoZosa authored Feb 13, 2023
2 parents ec3a79c + f59fca5 commit 95c5ca1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .mutmut-cache
Git LFS file not shown
9 changes: 7 additions & 2 deletions tests/structlog_sentry_logger/test__config.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,15 +246,20 @@ def mock_err(*args: Any, **kwargs: Any) -> None:
raise git.GitCommandError(redacted_command, status, stderr_value, stdout_value)

# Initialize and cd into a dummy Git repo
git.Repo.init(tmp_path, bare=False)
git_repo = git.Repo.init(tmp_path, bare=False)
os.chdir(tmp_path)

# Patch the underlying method which executes git commands. This will make any
# git command error out with the "dubious ownership" error
monkeypatch.setattr(git.Git, "_call_process", mock_err)

# Demonstrate that the "dubious ownership" error is raised with the library's
# previous method of inferring the git repo root dir
with pytest.raises(git.CommandError):
_ = git_repo.git.rev_parse("--show-toplevel")

# Validate a "dubious ownership" error is *not* raised when attempting to infer the
# project root directory
# project root directory via the current library method
assert tmp_path == structlog_sentry_logger._config.get_git_root()


Expand Down

0 comments on commit 95c5ca1

Please sign in to comment.