Skip to content

Commit 0bb2e00

Browse files
committed
Test worktree support
1 parent 9de86eb commit 0bb2e00

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/test_utilities.py

Lines changed: 22 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,27 @@ def test_utilities_get_gitrootpath_function_returns_proper_path_three_levels_up(
5657
assert os.path.isdir(gitdir_path) is True
5758

5859

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

0 commit comments

Comments
 (0)