patterns converted

This commit is contained in:
bigtedde 2023-07-07 17:50:44 -04:00
parent 0a104a3435
commit 7e14361700
1 changed files with 19 additions and 18 deletions

View File

@ -4,23 +4,24 @@ 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_basic():
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 filter(Item(path="deep enough/file"))
assert filter(Item(path="something/dir/file"))
def test_empty():
matcher = PatternMatcher(fallback=True)
filter = build_filter(matcher, 0)
assert filter(Item(path="anything"))
def test_strip_components():
matcher = PatternMatcher(fallback=True)
filter = build_filter(matcher, strip_components=1)
assert not filter(Item(path="shallow"))
assert filter(Item(path="deep enough/file"))
assert filter(Item(path="something/dir/file"))