Forráskód Böngészése

move patterns tests to own module

Thomas Waldmann 2 éve
szülő
commit
f94eec199f

+ 0 - 27
src/borg/testsuite/archiver/__init__.py

@@ -7,7 +7,6 @@ import subprocess
 import sys
 import tempfile
 import time
-import unittest
 from configparser import ConfigParser
 from datetime import datetime
 from io import BytesIO, StringIO
@@ -17,15 +16,12 @@ import pytest
 from ... import xattr, helpers, platform
 from ...archive import Archive
 from ...archiver import Archiver, PURE_PYTHON_MSGPACK_WARNING
-from ...archiver._common import build_filter
 from ...cache import Cache
 from ...constants import *  # NOQA
 from ...helpers import Location
 from ...helpers import EXIT_SUCCESS
 from ...helpers import bin_to_hex
 from ...manifest import Manifest
-from ...patterns import IECommand, PatternMatcher, parse_pattern
-from ...item import Item
 from ...logger import setup_logging
 from ...remote import RemoteRepository
 from ...repository import Repository
@@ -367,26 +363,3 @@ class RemoteArchiverTestCaseBase:
 
     def open_repository(self):
         return RemoteRepository(Location(self.repository_location))
-
-
-class TestBuildFilter:
-    def test_basic(self):
-        matcher = PatternMatcher()
-        matcher.add([parse_pattern("included")], IECommand.Include)
-        filter = build_filter(matcher, 0)
-        assert filter(Item(path="included"))
-        assert filter(Item(path="included/file"))
-        assert not filter(Item(path="something else"))
-
-    def test_empty(self):
-        matcher = PatternMatcher(fallback=True)
-        filter = build_filter(matcher, 0)
-        assert filter(Item(path="anything"))
-
-    def test_strip_components(self):
-        matcher = PatternMatcher(fallback=True)
-        filter = build_filter(matcher, strip_components=1)
-        assert not filter(Item(path="shallow"))
-        assert not filter(Item(path="shallow/"))  # can this even happen? paths are normalized...
-        assert filter(Item(path="deep enough/file"))
-        assert filter(Item(path="something/dir/file"))

+ 27 - 0
src/borg/testsuite/archiver/patterns.py

@@ -0,0 +1,27 @@
+from ...archiver._common import build_filter
+from ...constants import *  # NOQA
+from ...patterns import IECommand, PatternMatcher, parse_pattern
+from ...item import Item
+
+
+class TestBuildFilter:
+    def test_basic(self):
+        matcher = PatternMatcher()
+        matcher.add([parse_pattern("included")], IECommand.Include)
+        filter = build_filter(matcher, 0)
+        assert filter(Item(path="included"))
+        assert filter(Item(path="included/file"))
+        assert not filter(Item(path="something else"))
+
+    def test_empty(self):
+        matcher = PatternMatcher(fallback=True)
+        filter = build_filter(matcher, 0)
+        assert filter(Item(path="anything"))
+
+    def test_strip_components(self):
+        matcher = PatternMatcher(fallback=True)
+        filter = build_filter(matcher, strip_components=1)
+        assert not filter(Item(path="shallow"))
+        assert not filter(Item(path="shallow/"))  # can this even happen? paths are normalized...
+        assert filter(Item(path="deep enough/file"))
+        assert filter(Item(path="something/dir/file"))