Browse Source

tests: move tests to testsuite.helpers.msgpack_test

Thomas Waldmann 2 months ago
parent
commit
95432a9466
2 changed files with 36 additions and 34 deletions
  1. 36 0
      src/borg/testsuite/helpers/msgpack_test.py
  2. 0 34
      src/borg/testsuite/helpers_test.py

+ 36 - 0
src/borg/testsuite/helpers/msgpack_test.py

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

+ 0 - 34
src/borg/testsuite/helpers_test.py

@@ -1,4 +1,3 @@
-import sys
 from argparse import ArgumentTypeError
 from argparse import ArgumentTypeError
 from datetime import datetime, timezone
 from datetime import datetime, timezone
 from io import StringIO, BytesIO
 from io import StringIO, BytesIO
@@ -10,9 +9,7 @@ from ..constants import *  # NOQA
 from ..helpers import ChunkIteratorFileWrapper, ChunkerParams
 from ..helpers import ChunkIteratorFileWrapper, ChunkerParams
 from ..helpers import chunkit
 from ..helpers import chunkit
 from ..helpers import iter_separated
 from ..helpers import iter_separated
-from ..helpers import is_slow_msgpack
 from ..helpers import classify_ec, max_ec
 from ..helpers import classify_ec, max_ec
-from ..platform import is_cygwin
 
 
 
 
 @pytest.mark.parametrize(
 @pytest.mark.parametrize(
@@ -154,37 +151,6 @@ def test_prune_split_no_archives():
     assert kept_because == {}
     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():
 def test_chunk_file_wrapper():
     cfw = ChunkIteratorFileWrapper(iter([b"abc", b"def"]))
     cfw = ChunkIteratorFileWrapper(iter([b"abc", b"def"]))
     assert cfw.read(2) == b"ab"
     assert cfw.read(2) == b"ab"