mirror of https://github.com/borgbackup/borg.git
check that borg does not require pytest for normal usage, fixes #6563
also: move the note about this to the very top of the affected modules.
This commit is contained in:
parent
dc89798496
commit
2c25123284
|
@ -1,3 +1,6 @@
|
||||||
|
# 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
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Self testing module
|
Self testing module
|
||||||
===================
|
===================
|
||||||
|
@ -12,6 +15,7 @@ To assert that self test discovery works correctly the number of tests is kept i
|
||||||
variable. SELFTEST_COUNT must be updated if new tests are added or removed to or from any of the tests
|
variable. SELFTEST_COUNT must be updated if new tests are added or removed to or from any of the tests
|
||||||
used here.
|
used here.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
@ -62,6 +66,10 @@ def selftest(logger):
|
||||||
result = SelfTestResult()
|
result = SelfTestResult()
|
||||||
test_suite = TestSuite()
|
test_suite = TestSuite()
|
||||||
for test_case in SELFTEST_CASES:
|
for test_case in SELFTEST_CASES:
|
||||||
|
module = sys.modules[test_case.__module__]
|
||||||
|
# a normal borg user does not have pytest installed, we must not require it in the test modules used here.
|
||||||
|
# note: this only detects the usual toplevel import
|
||||||
|
assert 'pytest' not in dir(module), "pytest must not be imported in %s" % module.__name__
|
||||||
test_suite.addTest(defaultTestLoader.loadTestsFromTestCase(test_case))
|
test_suite.addTest(defaultTestLoader.loadTestsFromTestCase(test_case))
|
||||||
test_suite.run(result)
|
test_suite.run(result)
|
||||||
result.log_results(logger)
|
result.log_results(logger)
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
|
# 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
|
||||||
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
from ..chunker import ChunkerFixed, Chunker, get_chunker, buzhash, buzhash_update
|
from ..chunker import ChunkerFixed, Chunker, get_chunker, buzhash, buzhash_update
|
||||||
from ..constants import * # NOQA
|
from ..constants import * # NOQA
|
||||||
from . import BaseTestCase
|
from . import BaseTestCase
|
||||||
|
|
||||||
# Note: these tests are part of the self test, do not use or import py.test functionality here.
|
|
||||||
# See borg.selftest for details. If you add/remove test methods, update SELFTEST_COUNT
|
|
||||||
|
|
||||||
|
|
||||||
def cf(chunks):
|
def cf(chunks):
|
||||||
"""chunk filter"""
|
"""chunk filter"""
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
|
# 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
|
||||||
|
|
||||||
from binascii import hexlify
|
from binascii import hexlify
|
||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
|
||||||
from ..crypto.low_level import AES256_CTR_HMAC_SHA256, AES256_OCB, CHACHA20_POLY1305, UNENCRYPTED, IntegrityError
|
from ..crypto.low_level import AES256_CTR_HMAC_SHA256, AES256_OCB, CHACHA20_POLY1305, UNENCRYPTED, IntegrityError
|
||||||
from ..crypto.low_level import bytes_to_long, bytes_to_int, long_to_bytes
|
from ..crypto.low_level import bytes_to_long, bytes_to_int, long_to_bytes
|
||||||
from ..crypto.low_level import hkdf_hmac_sha512
|
from ..crypto.low_level import hkdf_hmac_sha512
|
||||||
|
@ -12,9 +14,6 @@ from ..helpers import msgpack
|
||||||
|
|
||||||
from . import BaseTestCase
|
from . import BaseTestCase
|
||||||
|
|
||||||
# Note: these tests are part of the self test, do not use or import py.test functionality here.
|
|
||||||
# See borg.selftest for details. If you add/remove test methods, update SELFTEST_COUNT
|
|
||||||
|
|
||||||
|
|
||||||
class CryptoTestCase(BaseTestCase):
|
class CryptoTestCase(BaseTestCase):
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
# 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 base64
|
import base64
|
||||||
import hashlib
|
import hashlib
|
||||||
import io
|
import io
|
||||||
|
@ -10,9 +13,6 @@ from .. import hashindex
|
||||||
from ..crypto.file_integrity import IntegrityCheckedFile, FileIntegrityError
|
from ..crypto.file_integrity import IntegrityCheckedFile, FileIntegrityError
|
||||||
from . import BaseTestCase, unopened_tempfile
|
from . import BaseTestCase, unopened_tempfile
|
||||||
|
|
||||||
# Note: these tests are part of the self test, do not use or import py.test functionality here.
|
|
||||||
# See borg.selftest for details. If you add/remove test methods, update SELFTEST_COUNT
|
|
||||||
|
|
||||||
|
|
||||||
def H(x):
|
def H(x):
|
||||||
# make some 32byte long thing that depends on x
|
# make some 32byte long thing that depends on x
|
||||||
|
|
Loading…
Reference in New Issue