소스 검색

remove hashindex tests from selftests

there isn't much left anyway, testing the core hashtable
functionality now happens in borghash project.

Also: switch these tests to pytest.
Thomas Waldmann 7 달 전
부모
커밋
ab08eea196
2개의 변경된 파일20개의 추가작업 그리고 23개의 파일을 삭제
  1. 2 3
      src/borg/selftest.py
  2. 18 20
      src/borg/testsuite/hashindex_test.py

+ 2 - 3
src/borg/selftest.py

@@ -21,13 +21,12 @@ import sys
 import time
 from unittest import TestResult, TestSuite, defaultTestLoader
 
-from .testsuite.hashindex_test import HashIndexRefcountingTestCase
 from .testsuite.crypto_test import CryptoTestCase
 from .testsuite.chunker_test import ChunkerTestCase
 
-SELFTEST_CASES = [HashIndexRefcountingTestCase, CryptoTestCase, ChunkerTestCase]
+SELFTEST_CASES = [CryptoTestCase, ChunkerTestCase]
 
-SELFTEST_COUNT = 13
+SELFTEST_COUNT = 11
 
 
 class SelfTestResult(TestResult):

+ 18 - 20
src/borg/testsuite/hashindex_test.py

@@ -1,11 +1,9 @@
-# Note: these tests are part of the self test, do not use or import pytest functionality here.
-#       See borg.selftest for details. If you add/remove test methods, update SELFTEST_COUNT
-
 import hashlib
 import struct
 
+import pytest
+
 from ..hashindex import ChunkIndex
-from . import BaseTestCase
 
 
 def H(x):
@@ -18,19 +16,19 @@ def H2(x):
     return hashlib.sha256(H(x)).digest()
 
 
-class HashIndexRefcountingTestCase(BaseTestCase):
-    def test_chunkindex_add(self):
-        chunks = ChunkIndex()
-        x = H2(1)
-        chunks.add(x, 5, 6)
-        assert chunks[x] == (5, 6)
-        chunks.add(x, 1, 2)
-        assert chunks[x] == (6, 2)
-
-    def test_keyerror(self):
-        chunks = ChunkIndex()
-        x = H2(1)
-        with self.assert_raises(KeyError):
-            chunks[x]
-        with self.assert_raises(struct.error):
-            chunks.add(x, -1, 0)
+def test_chunkindex_add():
+    chunks = ChunkIndex()
+    x = H2(1)
+    chunks.add(x, 5, 6)
+    assert chunks[x] == (5, 6)
+    chunks.add(x, 1, 2)
+    assert chunks[x] == (6, 2)
+
+
+def test_keyerror():
+    chunks = ChunkIndex()
+    x = H2(1)
+    with pytest.raises(KeyError):
+        chunks[x]
+    with pytest.raises(struct.error):
+        chunks.add(x, -1, 0)