Forráskód Böngészése

Add DepdendencyMissing class

Jelmer Vernooij 3 hónapja
szülő
commit
59e12925bd

+ 5 - 0
tests/__init__.py

@@ -45,6 +45,11 @@ from unittest import SkipTest, expectedFailure, skipIf
 from unittest import TestCase as _TestCase
 
 
+class DependencyMissing(SkipTest):
+    def __init__(self, dependency: str) -> None:
+        super().__init__(f"Dependency {dependency} missing")
+
+
 class TestCase(_TestCase):
     def setUp(self) -> None:
         super().setUp()

+ 3 - 3
tests/test_fastexport.py

@@ -27,7 +27,7 @@ from dulwich.objects import ZERO_SHA, Blob, Commit, Tree
 from dulwich.repo import MemoryRepo
 from dulwich.tests.utils import build_commit_graph
 
-from . import SkipTest, TestCase
+from . import DependencyMissing, TestCase
 
 
 class GitFastExporterTests(TestCase):
@@ -40,7 +40,7 @@ class GitFastExporterTests(TestCase):
         try:
             from dulwich.fastexport import GitFastExporter
         except ImportError as exc:
-            raise SkipTest("python-fastimport not available") from exc
+            raise DependencyMissing("python-fastimport") from exc
         self.fastexporter = GitFastExporter(self.stream, self.store)
 
     def test_emit_blob(self) -> None:
@@ -88,7 +88,7 @@ class GitImportProcessorTests(TestCase):
         try:
             from dulwich.fastexport import GitImportProcessor
         except ImportError as exc:
-            raise SkipTest("python-fastimport not available") from exc
+            raise DependencyMissing("python-fastimport") from exc
         self.processor = GitImportProcessor(self.repo)
 
     def test_reset_handler(self) -> None:

+ 3 - 1
tests/test_merge.py

@@ -7,6 +7,8 @@ from dulwich.merge import MergeConflict, Merger, three_way_merge
 from dulwich.objects import Blob, Commit, Tree
 from dulwich.repo import MemoryRepo
 
+from . import DependencyMissing
+
 
 class MergeTests(unittest.TestCase):
     """Tests for merge functionality."""
@@ -15,7 +17,7 @@ class MergeTests(unittest.TestCase):
         self.repo = MemoryRepo()
         # Check if merge3 module is available
         if importlib.util.find_spec("merge3") is None:
-            raise unittest.SkipTest("merge3 module not available, skipping merge tests")
+            raise DependencyMissing("merge3")
         self.merger = Merger(self.repo.object_store)
 
     def test_merge_blobs_no_conflict(self):

+ 3 - 1
tests/test_merge_drivers.py

@@ -35,6 +35,8 @@ from dulwich.merge_drivers import (
 )
 from dulwich.objects import Blob
 
+from . import DependencyMissing
+
 
 class _TestMergeDriver:
     """Test merge driver implementation."""
@@ -212,7 +214,7 @@ class MergeBlobsWithDriversTests(unittest.TestCase):
         """Set up test fixtures."""
         # Check if merge3 module is available
         if importlib.util.find_spec("merge3") is None:
-            raise unittest.SkipTest("merge3 module not available, skipping merge tests")
+            raise DependencyMissing("merge3")
 
         # Reset global registry
         global _merge_driver_registry

+ 2 - 2
tests/test_patch.py

@@ -37,7 +37,7 @@ from dulwich.patch import (
     write_tree_diff,
 )
 
-from . import SkipTest, TestCase
+from . import DependencyMissing, SkipTest, TestCase
 
 
 class WriteCommitPatchTests(TestCase):
@@ -701,7 +701,7 @@ class PatienceDiffTests(TestCase):
         try:
             import patiencediff  # noqa: F401
         except ImportError:
-            raise SkipTest("patiencediff not available")
+            raise DependencyMissing("patiencediff")
 
     def test_unified_diff_with_patience_available(self) -> None:
         """Test unified_diff_with_algorithm with patience if available."""