mirror of
https://github.com/borgbackup/borg.git
synced 2026-06-11 01:41:57 -04:00
tests: move tests to testsuite.helpers.msgpack_test
This commit is contained in:
parent
a3124cbed6
commit
95432a9466
2 changed files with 36 additions and 34 deletions
36
src/borg/testsuite/helpers/msgpack_test.py
Normal file
36
src/borg/testsuite/helpers/msgpack_test.py
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import sys
|
||||
import pytest
|
||||
|
||||
from ...helpers.msgpack import is_slow_msgpack
|
||||
from ...platform import is_cygwin
|
||||
|
||||
|
||||
def expected_py_mp_slow_combination():
|
||||
"""do we expect msgpack to be slow in this environment?"""
|
||||
# we need to import upstream msgpack package here, not helpers.msgpack:
|
||||
import msgpack
|
||||
|
||||
# msgpack is slow on cygwin
|
||||
if is_cygwin:
|
||||
return True
|
||||
# msgpack < 1.0.6 did not have py312 wheels
|
||||
if sys.version_info[:2] == (3, 12) and msgpack.version < (1, 0, 6):
|
||||
return True
|
||||
# otherwise we expect msgpack to be fast!
|
||||
return False
|
||||
|
||||
|
||||
@pytest.mark.skipif(expected_py_mp_slow_combination(), reason="ignore expected slow msgpack")
|
||||
def test_is_slow_msgpack():
|
||||
# we need to import upstream msgpack package here, not helpers.msgpack:
|
||||
import msgpack
|
||||
import msgpack.fallback
|
||||
|
||||
saved_packer = msgpack.Packer
|
||||
try:
|
||||
msgpack.Packer = msgpack.fallback.Packer
|
||||
assert is_slow_msgpack()
|
||||
finally:
|
||||
msgpack.Packer = saved_packer
|
||||
# this tests that we have fast msgpack on test platform:
|
||||
assert not is_slow_msgpack()
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
import sys
|
||||
from argparse import ArgumentTypeError
|
||||
from datetime import datetime, timezone
|
||||
from io import StringIO, BytesIO
|
||||
|
|
@ -10,9 +9,7 @@ from ..constants import * # NOQA
|
|||
from ..helpers import ChunkIteratorFileWrapper, ChunkerParams
|
||||
from ..helpers import chunkit
|
||||
from ..helpers import iter_separated
|
||||
from ..helpers import is_slow_msgpack
|
||||
from ..helpers import classify_ec, max_ec
|
||||
from ..platform import is_cygwin
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
|
@ -154,37 +151,6 @@ def test_prune_split_no_archives():
|
|||
assert kept_because == {}
|
||||
|
||||
|
||||
def expected_py_mp_slow_combination():
|
||||
"""do we expect msgpack to be slow in this environment?"""
|
||||
# we need to import upstream msgpack package here, not helpers.msgpack:
|
||||
import msgpack
|
||||
|
||||
# msgpack is slow on cygwin
|
||||
if is_cygwin:
|
||||
return True
|
||||
# msgpack < 1.0.6 did not have py312 wheels
|
||||
if sys.version_info[:2] == (3, 12) and msgpack.version < (1, 0, 6):
|
||||
return True
|
||||
# otherwise we expect msgpack to be fast!
|
||||
return False
|
||||
|
||||
|
||||
@pytest.mark.skipif(expected_py_mp_slow_combination(), reason="ignore expected slow msgpack")
|
||||
def test_is_slow_msgpack():
|
||||
# we need to import upstream msgpack package here, not helpers.msgpack:
|
||||
import msgpack
|
||||
import msgpack.fallback
|
||||
|
||||
saved_packer = msgpack.Packer
|
||||
try:
|
||||
msgpack.Packer = msgpack.fallback.Packer
|
||||
assert is_slow_msgpack()
|
||||
finally:
|
||||
msgpack.Packer = saved_packer
|
||||
# this tests that we have fast msgpack on test platform:
|
||||
assert not is_slow_msgpack()
|
||||
|
||||
|
||||
def test_chunk_file_wrapper():
|
||||
cfw = ChunkIteratorFileWrapper(iter([b"abc", b"def"]))
|
||||
assert cfw.read(2) == b"ab"
|
||||
|
|
|
|||
Loading…
Reference in a new issue