Commit 555c22cd authored by Kai Willadsen's avatar Kai Willadsen

test: Add a new minimal test for shell-based filter matching

parent 2a3bb1b5
import pytest
@pytest.mark.parametrize("patterns,filename,expected_match", [
([r'*.csv'], 'foo.csv', True),
([r'*.cvs'], 'foo.csv', False),
([r'*.csv *.xml'], 'foo.csv', True),
([r'*.csv *.xml'], 'foo.xml', True),
([r'*.csv', r'*.xml'], 'foo.csv', True),
([r'*.csv', r'*.xml'], 'foo.xml', True),
([r'*.csv', r'*.xml'], 'dumbtest', False),
([r'thing*csv'], 'thingcsv', True),
([r'thing*csv'], 'thingwhatevercsv', True),
([r'thing*csv'], 'csvthing', False),
def test_file_filters(patterns, filename, expected_match):
from meld.filters import FilterEntry
filters = [
FilterEntry.new_from_gsetting(("name", True, p), FilterEntry.SHELL)
for p in patterns
# All of the dirdiff logic is "does this match any filter", so
# that's what we test here, even if it looks a bit weird.
match = any(f.filter.match(filename) for f in filters)
assert match == expected_match
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment