Skip to content

Commit c1d2dec

Browse files
committed
Test worktree support
1 parent 2065d1e commit c1d2dec

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/test_utilities.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# -*- coding: utf-8 -*-
33

44
import os
5+
import subprocess
56

67
import pytest
78

@@ -56,6 +57,31 @@ def test_utilities_get_gitrootpath_function_returns_proper_path_three_levels_up(
5657
assert os.path.isdir(gitdir_path) is True
5758

5859

60+
@pytest.fixture
61+
def worktree_fixture():
62+
subprocess.check_call(
63+
["git", "worktree", "add", "--detach", "/tmp/font-v", "HEAD^"]
64+
)
65+
yield
66+
subprocess.call(
67+
[
68+
"git",
69+
"worktree",
70+
"remove",
71+
"/tmp/font-v",
72+
]
73+
)
74+
75+
76+
def test_utilities_get_gitrootpath_function_returns_proper_path_from_worktree(
77+
worktree_fixture,
78+
):
79+
filepath = "/tmp/font-v/README.md"
80+
gitdir_path = get_git_root_path(filepath)
81+
assert os.path.basename(gitdir_path) == "font-v"
82+
assert os.path.isdir(gitdir_path) is True
83+
84+
5985
def test_utilities_get_gitrootpath_function_raises_ioerror_six_levels_up():
6086
with pytest.raises(IOError):
6187
filepath = "tests/testfiles/deepdir/deepdir2/deepdir3/deepdir4/test.txt"

0 commit comments

Comments
 (0)