Browse Source

Fix test failures

Jelmer Vernooij 4 months ago
parent
commit
3878e14307
2 changed files with 11 additions and 19 deletions
  1. 6 15
      dulwich/tests/test_object_store.py
  2. 5 4
      tests/test_pack.py

+ 6 - 15
dulwich/tests/test_object_store.py

@@ -20,7 +20,7 @@
 
 """Tests for the object store interface."""
 
-from typing import TYPE_CHECKING
+from typing import TYPE_CHECKING, Any, Callable
 from unittest import skipUnless
 
 from dulwich.index import commit_tree
@@ -53,20 +53,11 @@ testobject = make_object(Blob, data=b"yummy data")
 class ObjectStoreTests:
     store: "BaseObjectStore"
 
-    def assertEqual(self, a, b) -> None:
-        raise NotImplementedError
-
-    def assertRaises(self, exc, func) -> None:
-        raise NotImplementedError
-
-    def assertNotIn(self, a, b) -> None:
-        raise NotImplementedError
-
-    def assertNotEqual(self, a, b) -> None:
-        raise NotImplementedError
-
-    def assertIn(self, a, b) -> None:
-        raise NotImplementedError
+    assertEqual: Callable[[object, object], None]
+    assertRaises: Callable[[type[Exception], Callable[[], Any]], None]
+    assertNotIn: Callable[[object, object], None]
+    assertNotEqual: Callable[[object, object], None]
+    assertIn: Callable[[object, object], None]
 
     def test_determine_wants_all(self) -> None:
         self.assertEqual(

+ 5 - 4
tests/test_pack.py

@@ -1295,8 +1295,6 @@ class DeltaChainIteratorTests(TestCase):
             self.assertEqual((sorted([b2.id, b3.id]),), (sorted(e.shas),))
 
     def test_ext_ref_deltified_object_based_on_itself(self) -> None:
-        td = tempfile.mkdtemp()
-        self.addCleanup(shutil.rmtree, td)
         b1_content = b"foo"
         (b1,) = self.store_blobs([b1_content])
         f = BytesIO()
@@ -1311,12 +1309,15 @@ class DeltaChainIteratorTests(TestCase):
         fsize = f.tell()
         f.seek(0)
         packdata = PackData.from_file(f, fsize)
+        td = tempfile.mkdtemp()
+        idx_path = os.path.join(td, "test.idx")
+        self.addCleanup(shutil.rmtree, td)
         packdata.create_index(
-            td.join("test.idx"),
+            idx_path,
             version=2,
             resolve_ext_ref=self.get_raw_no_repeat,
         )
-        packindex = load_pack_index(td.join("test.idx"))
+        packindex = load_pack_index(idx_path)
         pack = Pack.from_objects(packdata, packindex)
         try:
             # Attempting to open this REF_DELTA object would loop forever