Skip to content

Commit

Permalink
Add test tempdir sanity check
Browse files Browse the repository at this point in the history
  • Loading branch information
akaihola committed Oct 24, 2021
1 parent 7c5dd3e commit 4dec618
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/darker/tests/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,25 @@
from darker.utils import GIT_DATEFORMAT, TextDocument


def test_tmp_path_sanity(tmp_path):
"""Make sure Pytest temporary directories aren't inside a Git repository"""
try:
result = git._git_check_output_lines(
["rev-parse", "--absolute-git-dir"], tmp_path, exit_on_error=False
)
except CalledProcessError as exc_info:
if exc_info.returncode != 128 or not exc_info.stderr.startswith(
"fatal: not a git repository"
):
raise
else:
output = "\n".join(result)
raise AssertionError(
f"Temporary directory {tmp_path} for tests is not clean."
f" There is a Git directory in {output}"
)


@pytest.mark.parametrize(
"revision_range, expect",
[
Expand Down

0 comments on commit 4dec618

Please sign in to comment.