Bladeren bron

skip tests that require merge3 when it's not available (#2002)

resolved in a same way as in #1760
Jakub Kulík 1 maand geleden
bovenliggende
commit
2d84f930b3
4 gewijzigde bestanden met toevoegingen van 48 en 4 verwijderingen
  1. 12 1
      tests/test_cli_merge.py
  2. 12 1
      tests/test_porcelain_cherry_pick.py
  3. 18 1
      tests/test_porcelain_merge.py
  4. 6 1
      tests/test_rebase.py

+ 12 - 1
tests/test_cli_merge.py

@@ -21,6 +21,7 @@
 
 """Tests for dulwich merge CLI command."""
 
+import importlib.util
 import os
 import tempfile
 import unittest
@@ -28,7 +29,7 @@ import unittest
 from dulwich import porcelain
 from dulwich.cli import main
 
-from . import TestCase
+from . import DependencyMissing, TestCase
 
 
 class CLIMergeTests(TestCase):
@@ -77,6 +78,11 @@ class CLIMergeTests(TestCase):
 
     def test_merge_with_conflicts(self):
         """Test CLI merge with conflicts."""
+
+        # Check if merge3 module is available
+        if importlib.util.find_spec("merge3") is None:
+            raise DependencyMissing("merge3")
+
         with tempfile.TemporaryDirectory() as tmpdir:
             # Initialize repo
             porcelain.init(tmpdir)
@@ -334,6 +340,11 @@ class CLIMergeTests(TestCase):
 
     def test_octopus_merge_with_conflicts(self):
         """Test CLI octopus merge with conflicts."""
+
+        # Check if merge3 module is available
+        if importlib.util.find_spec("merge3") is None:
+            raise DependencyMissing("merge3")
+
         with tempfile.TemporaryDirectory() as tmpdir:
             # Initialize repo
             porcelain.init(tmpdir)

+ 12 - 1
tests/test_porcelain_cherry_pick.py

@@ -21,12 +21,13 @@
 
 """Tests for porcelain cherry-pick functionality."""
 
+import importlib.util
 import os
 import tempfile
 
 from dulwich import porcelain
 
-from . import TestCase
+from . import DependencyMissing, TestCase
 
 
 class PorcelainCherryPickTests(TestCase):
@@ -107,6 +108,11 @@ class PorcelainCherryPickTests(TestCase):
 
     def test_cherry_pick_conflict(self):
         """Test cherry-pick with conflicts."""
+
+        # Check if merge3 module is available
+        if importlib.util.find_spec("merge3") is None:
+            raise DependencyMissing("merge3")
+
         with tempfile.TemporaryDirectory() as tmpdir:
             # Initialize repo
             porcelain.init(tmpdir)
@@ -164,6 +170,11 @@ class PorcelainCherryPickTests(TestCase):
 
     def test_cherry_pick_abort(self):
         """Test aborting a cherry-pick."""
+
+        # Check if merge3 module is available
+        if importlib.util.find_spec("merge3") is None:
+            raise DependencyMissing("merge3")
+
         with tempfile.TemporaryDirectory() as tmpdir:
             # Initialize repo
             porcelain.init(tmpdir)

+ 18 - 1
tests/test_porcelain_merge.py

@@ -21,6 +21,7 @@
 
 """Tests for porcelain merge functionality."""
 
+import importlib.util
 import os
 import tempfile
 import unittest
@@ -28,7 +29,7 @@ import unittest
 from dulwich import porcelain
 from dulwich.repo import Repo
 
-from . import TestCase
+from . import DependencyMissing, TestCase
 
 
 class PorcelainMergeTests(TestCase):
@@ -166,6 +167,10 @@ class PorcelainMergeTests(TestCase):
                 self.assertEqual(f.read(), "Master file2\n")
 
     def test_merge_with_conflicts(self):
+        # Check if merge3 module is available
+        if importlib.util.find_spec("merge3") is None:
+            raise DependencyMissing("merge3")
+
         """Test merge with conflicts."""
         with tempfile.TemporaryDirectory() as tmpdir:
             # Initialize repo
@@ -339,6 +344,10 @@ class PorcelainMergeTests(TestCase):
                 self.assertEqual(f.read(), "Branch3 modified file3\n")
 
     def test_octopus_merge_with_conflicts(self):
+        # Check if merge3 module is available
+        if importlib.util.find_spec("merge3") is None:
+            raise DependencyMissing("merge3")
+
         """Test that octopus merge refuses to proceed with conflicts."""
         with tempfile.TemporaryDirectory() as tmpdir:
             # Initialize repo
@@ -520,6 +529,10 @@ class PorcelainMergeTreeTests(TestCase):
             self.assertIn(b"file3.txt", merged_tree)
 
     def test_merge_tree_with_conflicts(self):
+        # Check if merge3 module is available
+        if importlib.util.find_spec("merge3") is None:
+            raise DependencyMissing("merge3")
+
         """Test merge_tree with conflicts."""
         with tempfile.TemporaryDirectory() as tmpdir:
             # Initialize repo
@@ -607,6 +620,10 @@ class PorcelainMergeTreeTests(TestCase):
             self.assertIn(b"file2.txt", merged_tree)
 
     def test_merge_tree_with_tree_objects(self):
+        # Check if merge3 module is available
+        if importlib.util.find_spec("merge3") is None:
+            raise DependencyMissing("merge3")
+
         """Test merge_tree with tree objects instead of commits."""
         with tempfile.TemporaryDirectory() as tmpdir:
             # Initialize repo

+ 6 - 1
tests/test_rebase.py

@@ -21,6 +21,7 @@
 
 """Tests for dulwich.rebase."""
 
+import importlib.util
 import os
 import tempfile
 
@@ -38,7 +39,7 @@ from dulwich.rebase import (
 from dulwich.repo import MemoryRepo, Repo
 from dulwich.tests.utils import make_commit
 
-from . import TestCase
+from . import DependencyMissing, TestCase
 
 
 class RebaserTestCase(TestCase):
@@ -163,6 +164,10 @@ class RebaserTestCase(TestCase):
         self.assertIn(b"file.txt", new_tree)
 
     def test_rebase_with_conflicts(self):
+        # Check if merge3 module is available
+        if importlib.util.find_spec("merge3") is None:
+            raise DependencyMissing("merge3")
+
         """Test rebase with merge conflicts."""
         self._setup_initial_commit()
         # Create feature branch with conflicting change