1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-03-09 21:57:24 +00:00

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.
This commit is contained in:
Thomas Waldmann 2024-10-25 19:14:57 +02:00
parent 03596e3651
commit ab08eea196
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01
2 changed files with 19 additions and 22 deletions

View file

@ -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):

View file

@ -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_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(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_keyerror():
chunks = ChunkIndex()
x = H2(1)
with pytest.raises(KeyError):
chunks[x]
with pytest.raises(struct.error):
chunks.add(x, -1, 0)