Pārlūkot izejas kodu

For tests that require symlink support, check if os has a symlink attr rather
than checking sys.platform or os.name.

Gary van der Merwe 10 gadi atpakaļ
vecāks
revīzija
b4d3b21095
2 mainītis faili ar 8 papildinājumiem un 9 dzēšanām
  1. 6 7
      dulwich/tests/test_index.py
  2. 2 2
      dulwich/tests/test_repository.py

+ 6 - 7
dulwich/tests/test_index.py

@@ -50,7 +50,10 @@ from dulwich.objects import (
     Tree,
     )
 from dulwich.repo import Repo
-from dulwich.tests import TestCase
+from dulwich.tests import (
+    TestCase,
+    skipIf,
+)
 
 class IndexTestCase(TestCase):
 
@@ -271,10 +274,8 @@ class BuildIndexTests(TestCase):
             # Verify no files
             self.assertEqual(['.git'], os.listdir(repo.path))
 
+    @skipIf(not getattr(os, 'symlink', None), 'Requires symlink support')
     def test_git_dir(self):
-        if os.name != 'posix':
-            self.skipTest("test depends on POSIX shell")
-
         repo_dir = tempfile.mkdtemp()
         self.addCleanup(shutil.rmtree, repo_dir)
         with closing(Repo.init(repo_dir)) as repo:
@@ -308,10 +309,8 @@ class BuildIndexTests(TestCase):
                 stat.S_IFREG | 0o644, 1, filee.id)
             self.assertFileContents(epath, b'd')
 
+    @skipIf(not getattr(os, 'symlink', None), 'Requires symlink support')
     def test_nonempty(self):
-        if os.name != 'posix':
-            self.skipTest("test depends on POSIX shell")
-
         repo_dir = tempfile.mkdtemp()
         self.addCleanup(shutil.rmtree, repo_dir)
         with closing(Repo.init(repo_dir)) as repo:

+ 2 - 2
dulwich/tests/test_repository.py

@@ -305,7 +305,7 @@ class RepositoryRootTests(TestCase):
         r = self.open_repo('ooo_merge.git')
         self.assertIsInstance(r.get_config_stack(), Config)
 
-    @skipIf(sys.platform == 'win32', 'Requires symlink support')
+    @skipIf(not getattr(os, 'symlink', None), 'Requires symlink support')
     def test_submodule(self):
         temp_dir = self.mkdtemp()
         self.addCleanup(shutil.rmtree, temp_dir)
@@ -565,7 +565,7 @@ class BuildRepoRootTests(TestCase):
         self.assertEqual(stat.S_IFREG | 0o644, a_mode)
         self.assertEqual(b'new contents', r[a_id].data)
 
-    @skipIf(sys.platform == 'win32', 'Requires symlink support')
+    @skipIf(not getattr(os, 'symlink', None), 'Requires symlink support')
     def test_commit_symlink(self):
         r = self._repo
         os.symlink('a', os.path.join(r.path, 'b'))