浏览代码

Fix test when run with tempdir on different windows drive.

Jelmer Vernooij 4 年之前
父节点
当前提交
884fd894f4
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      dulwich/tests/test_repository.py

+ 7 - 1
dulwich/tests/test_repository.py

@@ -449,7 +449,13 @@ class RepositoryRootTests(TestCase):
         repo_dir = os.path.join(os.path.dirname(__file__), 'data', 'repos')
         shutil.copytree(os.path.join(repo_dir, 'a.git'),
                         os.path.join(temp_dir, 'a.git'), symlinks=True)
-        rel = os.path.relpath(os.path.join(repo_dir, 'submodule'), temp_dir)
+        try:
+            rel = os.path.relpath(
+                os.path.join(repo_dir, 'submodule'), temp_dir)
+        except ValueError:
+            # On windows, these two paths could be on different drives,
+            # making it impossible to determine a relative path.
+            rel = os.path.join(repo_dir, 'submodule')
         os.symlink(os.path.join(rel, 'dotgit'), os.path.join(temp_dir, '.git'))
         with Repo(temp_dir) as r:
             self.assertEqual(r.head(),