Skip to content

Commit ffe2911

Browse files
authored
Make git init test more robust (#433)
This makes the git initialisation test more robust by explicitly specifying the directory that should be a git repository. Prevents a false positive if the cookiecutter package dir doesn't have a `.git` directory, but one its parent directories does.
1 parent ea3f850 commit ffe2911

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

tests/test_git_init.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ def test_initialisation_of_git_repo(
2929
git_status = subprocess.run( # noqa: S603
3030
[ # noqa: S607
3131
"git",
32-
"-C",
33-
f"{test_project_dir}",
32+
f"--git-dir={test_project_dir / '.git'}",
3433
"status",
3534
],
3635
capture_output=True,
@@ -40,10 +39,7 @@ def test_initialisation_of_git_repo(
4039

4140
if not initialise_git_repository:
4241
# should not have found git
43-
assert (
44-
git_status.stderr
45-
== "fatal: not a git repository (or any of the parent directories): .git\n"
46-
)
42+
assert "fatal: not a git repository" in git_status.stderr
4743
return # nothing more to test
4844

4945
# git status should succeed

0 commit comments

Comments
 (0)