Esempio n. 1
0
    def test_match_twin_elements_bound_end(self):
        s = Section(['test', "a*"])
        s.bound_end = True
        path = []
        matches = [index for index in s.match_iter(path, 0)]
        assert [] == matches

        path = "test".split("/")
        matches = [index for index in s.match_iter(path, 0)]
        assert [] == matches

        path = "test/bin".split("/")
        matches = [index for index in s.match_iter(path, 0)]
        assert [] == matches

        path = "test/andrew".split("/")
        matches = [index for index in s.match_iter(path, 0)]
        assert [2] == matches

        path = "test/andrew/bin/test/ast/test/another".split("/")
        matches = [index for index in s.match_iter(path, 0)]
        assert [7] == matches

        path = "not/util/bin/test/ast/not".split("/")
        matches = [index for index in s.match_iter(path, 0)]
        assert [] == matches
Esempio n. 2
0
    def test_match_twin_elements_no_bindings(self):
        s = Section(['test', "a*"])
        path = []
        matches = [index for index in s.match_iter(path, 0)]
        assert [] == matches

        path = "test".split("/")
        matches = [index for index in s.match_iter(path, 0)]
        assert [] == matches

        path = "test/bin".split("/")
        matches = [index for index in s.match_iter(path, 0)]
        assert [] == matches

        path = "test/andrew".split("/")
        matches = [index for index in s.match_iter(path, 0)]
        assert [2] == matches

        path = "test/andrew/bin/test/ast/test/another".split("/")
        matches = [index for index in s.match_iter(path, 0)]
        assert [2, 5, 7] == matches

        path = "not/util/bin/test/ast/not".split("/")
        matches = [index for index in s.match_iter(path, 0)]
        assert [5] == matches
Esempio n. 3
0
    def test_basic(self):
        s = Section(['test'])
        assert s.str == "test"
        assert s.elements[0] == ConstantMatcher("test")

        s = Section(["test", "bin"])
        assert s.str == "test/bin"
        assert s.elements[0] == ConstantMatcher("test")
        assert s.elements[1] == ConstantMatcher("bin")

        s = Section(["????", "test", "bin"])
        assert s.str == "????/test/bin"
        assert s.elements[0] == FNMatcher("????")
        assert s.elements[1] == ConstantMatcher("test")
        assert s.elements[2] == ConstantMatcher("bin")
Esempio n. 4
0
 def test_single_match_not_beginning(self):
     s = Section(['test'])
     path = "test/andrew/bin/test/ast/test/another".split("/")
     matches = [index for index in s.match_iter(path, 2)]
     assert [4, 6] == matches
     matches = [index for index in s.match_iter(path, 3)]
     assert [4, 6] == matches
     matches = [index for index in s.match_iter(path, 4)]
     assert [6] == matches
     matches = [index for index in s.match_iter(path, 5)]
     assert [6] == matches
     matches = [index for index in s.match_iter(path, 6)]
     assert [] == matches
     matches = [index for index in s.match_iter(path, 7)]
     assert [] == matches
     matches = [index for index in s.match_iter(path, 8)]
     assert [] == matches
Esempio n. 5
0
    def test_compilation_bound_start(self):
        p = Pattern.create("/*.py")
        assert p.bound_start is True
        assert p.bound_end is True
        assert str(p.file_pattern) == "*.py"
        assert p.sections == []

        p = Pattern.create("/test/*.py")
        assert p.bound_start is True
        assert p.bound_end is True
        assert str(p.file_pattern) == "*.py"
        assert p.sections == [Section(["test"])]

        p = Pattern.create("/test/dir/*")
        assert p.bound_start is True
        assert p.bound_end is True
        assert p.file_pattern == "*"
        assert p.sections == [Section(["test", "dir"])]

        p = Pattern.create("/start/**/test/*.py")
        assert p.bound_start is True
        assert p.bound_end is True
        assert str(p.file_pattern) == "*.py"
        assert p.sections == [Section(["start"]), Section(["test"])]

        p = Pattern.create("/start/**/test/**/*.py")
        assert p.bound_start is True
        assert p.bound_end is False
        assert str(p.file_pattern) == "*.py"
        assert p.sections == [Section(["start"]), Section(["test"])]
Esempio n. 6
0
    def test_match_bound_start(self):
        s = Section(['test', "a*"])
        s.bound_start = True
        path = "test".split("/")
        matches = [index for index in s.match_iter(path, 0)]
        assert [] == matches

        path = "test/andrew/bin/test/ast/test/another".split("/")
        matches = [index for index in s.match_iter(path, 0)]
        assert [2] == matches

        path = "test/andrew/bin/test/ast/test/another".split("/")
        matches = [index for index in s.match_iter(path, 1)]
        assert [] == matches
Esempio n. 7
0
    def test_match_single_bound_end(self):
        s = Section(['test'])
        s.bound_end = True
        path = []
        matches = [index for index in s.match_iter(path, 0)]
        assert [] == matches

        path = "test".split("/")
        matches = [index for index in s.match_iter(path, 0)]
        assert [1] == matches

        path = "not".split("/")
        matches = [index for index in s.match_iter(path, 0)]
        assert [] == matches

        path = "test/util/bin/test/last/test".split("/")
        matches = [index for index in s.match_iter(path, 0)]
        assert [6] == matches

        path = "not/util/bin/test/last/not".split("/")
        matches = [index for index in s.match_iter(path, 0)]
        assert [] == matches
Esempio n. 8
0
    def test_match_single_no_bindings(self):
        s = Section(['test'])
        path = []
        matches = [index for index in s.match_iter(path, 0)]
        assert [] == matches

        path = "test".split("/")
        matches = [index for index in s.match_iter(path, 0)]
        assert [1] == matches

        path = "not".split("/")
        matches = [index for index in s.match_iter(path, 0)]
        assert [] == matches

        path = "test/util/bin/test/last/test".split("/")
        matches = [index for index in s.match_iter(path, 0)]
        assert [1, 4, 6] == matches

        path = "not/util/bin/test/last/not".split("/")
        matches = [index for index in s.match_iter(path, 0)]
        assert [4] == matches
Esempio n. 9
0
    def test_multi_match_not_beginning(self):
        s = Section(['test', 'a*'])
        path = "test".split("/")
        matches = [index for index in s.match_iter(path, 1)]
        assert [] == matches

        path = "test/andrew".split("/")
        matches = [index for index in s.match_iter(path, 1)]
        assert [] == matches

        path = "test/andrew/bin/test/ast/test/another".split("/")
        matches = [index for index in s.match_iter(path, 2)]
        assert [5, 7] == matches
        matches = [index for index in s.match_iter(path, 3)]
        assert [5, 7] == matches
        matches = [index for index in s.match_iter(path, 4)]
        assert [7] == matches
        matches = [index for index in s.match_iter(path, 5)]
        assert [7] == matches
        matches = [index for index in s.match_iter(path, 6)]
        assert [] == matches
        matches = [index for index in s.match_iter(path, 7)]
        assert [] == matches
        matches = [index for index in s.match_iter(path, 8)]
        assert [] == matches