예제 #1
0
def test_matches_values():
    assert Matcher("tag:bla=2").matches(FakeMetadata("something", {"bla": 2}))
    assert not Matcher("tag:bla=2").matches(FakeMetadata("something", {"bla": 3}))
    assert Matcher("tag:bla=hello").matches(FakeMetadata("something", {"bla": "hello"}))
    assert not Matcher("tag:bla=bye").matches(
        FakeMetadata("something", {"bla": "hello"})
    )
예제 #2
0
def test_matches_values():
    assert Matcher('tag:bla=2').matches(FakeMetadata('something', {'bla': 2}))
    assert not Matcher('tag:bla=2').matches(
        FakeMetadata('something', {'bla': 3}))
    assert Matcher('tag:bla=hello').matches(
        FakeMetadata('something', {'bla': 'hello'}))
    assert not Matcher('tag:bla=bye').matches(
        FakeMetadata('something', {'bla': 'hello'}))
예제 #3
0
def test_matcher(pattern, matching, not_matching):
    matcher = Matcher(pattern)
    for string in matching:
        assert matcher.matches(FakeMetadata(
            string)), "Pattern {!r} unexpectedly does not match {!r}".format(
                pattern, string)

    for string in not_matching:
        assert not matcher.matches(FakeMetadata(
            string)), "Pattern {!r} unexpectedly matches {!r}".format(
                pattern, string)
예제 #4
0
def test_matcher():
    for pattern, matching, not_matching in [
            ('xy', ['blapxy'], ['blap']),
            ('not x', ['blap', 'yyy'], ['blapx', 'xy']),
            ('x and y', ['xy', 'yx', 'x kjfldkjfd y'], ['x', 'y', 'xx']),
            ('(x and some.string) and not z', ['xysome.string', 'some.stringyx'], ['z', 'xysome.stringz']),
            ('exact(x=y)(y=z)', ['exact(x=y)(y=z)'], ['exlact(x=y)(y=z)']),
            ]:

        matcher = Matcher(pattern)
        for string in matching:
            assert matcher.matches(FakeMetadata(string))
        for string in not_matching:
            assert not matcher.matches(FakeMetadata(string))
예제 #5
0
def test_matcher():
    for pattern, matching, not_matching in [
            ('xy', ['blapxy'], ['blap']),
            ('not x', ['blap', 'yyy'], ['blapx', 'xy']),
            ('x and y', ['xy', 'yx', 'x kjfldkjfd y'], ['x', 'y', 'xx']),
            ('(x and some.string) and not z', ['xysome.string', 'some.stringyx'], ['z', 'xysome.stringz']),
            ('exact(x=y)(y=z)', ['exact(x=y)(y=z)'], ['exlact(x=y)(y=z)']),
    ]:

        matcher = Matcher(pattern)
        for string in matching:
            assert matcher.matches(FakeMetadata(string))
        for string in not_matching:
            assert not matcher.matches(FakeMetadata(string))
예제 #6
0
def tet_matches_tag_whitespaces():
    assert Matcher("tag:    bla").matches(FakeMetadata("something",
                                                       {"bla": 2}))
    assert not Matcher("tag: bla").matches(FakeMetadata("bla", {"bloop": 2}))
예제 #7
0
def test_matches_tag_exactly():
    matcher = Matcher("tag:bla")
    assert matcher.matches(FakeMetadata("something", {"bla": 2}))
    for non_matching_tag in ("bla1", "1bla", "1bla2"):
        assert not matcher.matches(
            FakeMetadata("something", {non_matching_tag: 2}))
예제 #8
0
def test_matches_tag_exclusively():
    assert Matcher("tag:bla").matches(FakeMetadata("something", {"bla": 2}))
    assert not Matcher("tag:bla").matches(FakeMetadata("bla", {"bloop": 2}))
예제 #9
0
def test_matches_tag():
    assert Matcher("bla").matches(FakeMetadata("something", {"bla": 2}))
    assert not Matcher("bla").matches(FakeMetadata("something", {"bloop": 2}))
    assert Matcher("substring").matches(
        FakeMetadata("something", {"xxxxsubstringxxx": 2}))
예제 #10
0
def test_test_name_matcher():
    test_name = "/path/to/testfile.py:TestName"
    m = FakeMetadata(test_name)
    assert not Matcher("not {}".format(test_name)).matches(m)
    assert Matcher(test_name).matches(m)
예제 #11
0
def test_matches_tag_exclusively():
    assert Matcher('tag:bla').matches(FakeMetadata('something', {'bla': 2}))
    assert not Matcher('tag:bla').matches(FakeMetadata('bla', {'bloop': 2}))
예제 #12
0
def test_matches_tag():
    assert Matcher('bla').matches(FakeMetadata('something', {'bla': 2}))
    assert not Matcher('bla').matches(FakeMetadata('something', {'bloop': 2}))
    assert Matcher('substring').matches(
        FakeMetadata('something', {'xxxxsubstringxxx': 2}))