From 0d9f2d146615bd51970121c62aa39aa50dcf1c59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 6 Aug 2021 23:23:44 +0200 Subject: [PATCH] Added a test for failing get_root_dir inside the git folder --- tests/git_test.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/git_test.py b/tests/git_test.py index 0dfadfa9..7cd1c549 100644 --- a/tests/git_test.py +++ b/tests/git_test.py @@ -19,6 +19,13 @@ def test_get_root_deeper(in_git_dir): assert os.path.normcase(git.get_root()) == expected +def test_get_root_in_git_sub_dir(in_git_dir): + expected = os.path.normcase(in_git_dir.strpath) + with pytest.raises(FatalError): + with in_git_dir.join('.git/objects').ensure_dir().as_cwd(): + assert os.path.normcase(git.get_root()) == expected + + def test_in_exactly_dot_git(in_git_dir): with in_git_dir.join('.git').as_cwd(), pytest.raises(FatalError): git.get_root()