Skip to content

Commit 8e5b8bb

Browse files
committed
Test worktree support
1 parent 2065d1e commit 8e5b8bb

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",
64+
"worktree",
65+
"add",
66+
"--detach",
67+
"/tmp/font-v",
68+
"HEAD^"
69+
])
70+
yield
71+
subprocess.call([
72+
"git",
73+
"worktree",
74+
"remove",
75+
"/tmp/font-v",
76+
])
77+
78+
def test_utilities_get_gitrootpath_function_returns_proper_path_from_worktree(worktree_fixture):
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)