Exemplo n.º 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"})
    )
Exemplo n.º 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'}))
Exemplo n.º 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)
Exemplo n.º 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))
Exemplo n.º 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))
Exemplo n.º 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}))
Exemplo n.º 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}))
Exemplo n.º 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}))
Exemplo n.º 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}))
Exemplo n.º 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)
Exemplo n.º 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}))
Exemplo n.º 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}))