Skip to content

Commit 50a8920

Browse files
committed
Fixing windows path issues in tests
1 parent 495ea64 commit 50a8920

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

tests/test_utils.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,21 @@ def test_has_git_false(self) -> None:
5454
with TemporaryDirectory() as temp_dir_no_git:
5555
os.chdir(temp_dir_no_git)
5656
self.assertFalse(has_git())
57-
os.chdir(self.temp_dir.name)
57+
os.chdir(self.temp_dir.name)
5858

5959
def test_get_git_root(self) -> None:
60-
self.assertTrue(get_git_root() in f'/private{self.temp_dir.name}')
60+
# Ideally should be self.temp_dir.name == get_git_root() but the OS may add a prefix like /private
61+
self.assertTrue(get_git_root().endswith(self.temp_dir.name))
6162

6263
def test_get_git_root_subdir(self) -> None:
63-
os.makedirs(os.path.join(self.temp_dir.name, 'subdir'))
64-
self.assertTrue(get_git_root() in f'/private{self.temp_dir.name}')
64+
subdir = os.path.join(self.temp_dir.name, 'subdir')
65+
os.makedirs(subdir)
66+
os.chdir(subdir)
67+
68+
# Ideally should be self.temp_dir.name == get_git_root() but the OS may add a prefix like /private
69+
self.assertTrue(get_git_root().endswith(self.temp_dir.name))
70+
71+
os.chdir(self.temp_dir.name)
6572

6673
def test_get_git_url_https(self) -> None:
6774
self.assertEqual(get_git_url(commit_hash=False), self.url)

0 commit comments

Comments
 (0)