Exemplo n.º 1
0
    def test_trivial_matches(self):
        self.assertTrue(globs.does_glob_match('abcd', 'abcd'))
        self.assertFalse(globs.does_glob_match('abc', 'abcd'))
        self.assertFalse(globs.does_glob_match('abcd', 'abc'))

        self.assertTrue(globs.does_glob_match('*', 'abcd'))
        self.assertFalse(globs.does_glob_match('abcd', '*'))

        self.assertTrue(globs.does_glob_match('?', 'c'))
        self.assertFalse(globs.does_glob_match('c', '?'))
Exemplo n.º 2
0
 def matches_component(self, component):
     if self.matchtype == 'plain':
         return self.matchdata == component
     if self.matchtype == 'glob':
         return glob_utils.does_glob_match(self.matchdata, component)
     raise AssertionError('Unhandled match type: ' + self.matchtype)
Exemplo n.º 3
0
 def test_simple_matches(self):
     self.assertTrue(globs.does_glob_match('abcd*', 'abcd'))
     self.assertTrue(globs.does_glob_match('*abcd', 'abcd'))
     self.assertTrue(globs.does_glob_match('ab*', 'abcd'))
     self.assertTrue(globs.does_glob_match('a*d', 'abcd'))
     self.assertTrue(globs.does_glob_match('ab*cd', 'abcd'))
     self.assertTrue(globs.does_glob_match('*d', 'abcd'))
     self.assertTrue(globs.does_glob_match('a*bc*d', 'abcd'))
     self.assertTrue(globs.does_glob_match('a*bc*d', 'antdbcethted'))
     self.assertTrue(globs.does_glob_match('ab?d', 'abcd'))
     self.assertTrue(globs.does_glob_match('?bcd', 'abcd'))
     self.assertTrue(globs.does_glob_match('abc?', 'abcd'))
     self.assertTrue(globs.does_glob_match('abc?*', 'abcd'))
     self.assertTrue(globs.does_glob_match('abc*?', 'abcd'))
     self.assertTrue(globs.does_glob_match('abc*?*', 'abcd'))
     self.assertTrue(globs.does_glob_match('a[b]cd', 'abcd'))
     self.assertTrue(globs.does_glob_match('a[abcd]cd', 'abcd'))
     self.assertTrue(globs.does_glob_match('a[!acd]cd', 'abcd'))
     self.assertTrue(globs.does_glob_match('ab[,]cd', 'ab,cd'))
     self.assertTrue(globs.does_glob_match('ab[ab,(]cd', 'ab,cd'))
     self.assertTrue(globs.does_glob_match('ab[!.]cd', 'ab,cd'))
     self.assertTrue(globs.does_glob_match('ab[!m7/)]cd', 'ab,cd'))
     self.assertTrue(globs.does_glob_match('a*[abcd]cd', 'abcd'))
     self.assertTrue(globs.does_glob_match('a*[abcd]cd', 'athtobcd'))
     self.assertTrue(globs.does_glob_match('a*[abcd]cd', 'abcbdbcd'))
     self.assertTrue(globs.does_glob_match('ab*[!m7/)]cd', 'ab,cd'))
     self.assertTrue(globs.does_glob_match('ab*[!m7/)]cd', 'abtoheu,cd'))
     self.assertTrue(globs.does_glob_match('ab*[!m7/)]cd', 'abm7m,cd'))
Exemplo n.º 4
0
    def test_special_chars(self):
        self.assertTrue(globs.does_glob_match('ab*cd', 'ab*cd'))
        self.assertTrue(globs.does_glob_match('ab[*]cd', 'ab*cd'))
        self.assertTrue(globs.does_glob_match('ab*cd', 'abtcd'))
        self.assertFalse(globs.does_glob_match('ab[*]cd', 'abtcd'))
        self.assertTrue(globs.does_glob_match('ab*cd', 'abcd'))
        self.assertFalse(globs.does_glob_match('ab[*]cd', 'abcd'))
        self.assertTrue(globs.does_glob_match('ab*cd', 'ablongecd'))
        self.assertFalse(globs.does_glob_match('ab[*]cd', 'ablongecd'))

        self.assertTrue(globs.does_glob_match('ab?cd', 'ab?cd'))
        self.assertTrue(globs.does_glob_match('ab[?]cd', 'ab?cd'))
        self.assertTrue(globs.does_glob_match('ab?cd', 'abtcd'))
        self.assertFalse(globs.does_glob_match('ab[?]cd', 'abtcd'))

        self.assertTrue(globs.does_glob_match('ab-cd', 'ab-cd'))
        self.assertTrue(globs.does_glob_match('ab[-]cd', 'ab-cd'))
        self.assertFalse(globs.does_glob_match('ab[-]cd', 'ab[-]cd'))
        self.assertTrue(globs.does_glob_match('ab[]]cd', 'ab]cd'))
        self.assertFalse(globs.does_glob_match('ab[]]cd', 'ab[]]cd'))
Exemplo n.º 5
0
 def test_range_non_matches(self):
     self.assertFalse(globs.does_glob_match('ab[a-z]cd', 'abcd'))
     self.assertFalse(globs.does_glob_match('ab[a-z]cd', 'ab4cd'))
     self.assertFalse(globs.does_glob_match('ab[a-z]cd', 'abDcd'))
     self.assertFalse(globs.does_glob_match('ab[a-z]cd', 'ab,cd'))
     self.assertFalse(globs.does_glob_match('ab[0-9]cd', 'abtcd'))
     self.assertFalse(globs.does_glob_match('ab[2-6]cd', 'ab8cd'))
     self.assertFalse(globs.does_glob_match('ab[2-6]cd', 'ab7cd'))
     self.assertFalse(globs.does_glob_match('ab[2-6]cd', 'ab9cd'))
     self.assertFalse(globs.does_glob_match('ab[2-6]cd', 'ab1cd'))
     self.assertFalse(globs.does_glob_match('ab[2-6]cd', 'ab0cd'))
     self.assertFalse(globs.does_glob_match('ab[fd-kt]cd', 'abbcd'))
     self.assertFalse(globs.does_glob_match('ab[fd-kt]cd', 'abmcd'))
     self.assertFalse(globs.does_glob_match('ab[fd-kt]cd', 'abzcd'))
     self.assertFalse(globs.does_glob_match('ab[fd-kt]cd', 'ab4cd'))
     self.assertFalse(globs.does_glob_match('ab[n]cd', 'abmcd'))
     self.assertFalse(globs.does_glob_match('ab[n]cd', 'abocd'))
     self.assertFalse(globs.does_glob_match('ab[f-i]cd', 'abecd'))
     self.assertFalse(globs.does_glob_match('ab[f-i]cd', 'abjcd'))
     self.assertFalse(globs.does_glob_match('ab[A-Z]cd', 'abcd'))
     self.assertFalse(globs.does_glob_match('ab[C-R]cd', 'abecd'))
     self.assertFalse(globs.does_glob_match('ab[C-R]cd', 'abBcd'))
     self.assertFalse(globs.does_glob_match('ab[C-R]cd', 'abScd'))
     self.assertFalse(globs.does_glob_match('ab[!4-7]cd', 'abcd'))
     self.assertFalse(globs.does_glob_match('ab[!4-7]cd', 'ab4cd'))
     self.assertFalse(globs.does_glob_match('ab[!4-7]cd', 'ab5cd'))
     self.assertFalse(globs.does_glob_match('ab[!4-7]cd', 'ab7cd'))
     self.assertFalse(globs.does_glob_match('ab*[2-6]cd', 'ab.cd'))
     self.assertFalse(globs.does_glob_match('ab*[2-6]cd', 'abthon.cd'))
     self.assertFalse(globs.does_glob_match('ab*[2-6]cd', 'ab4536.cd'))
     self.assertFalse(globs.does_glob_match('ab*[!4-7]cd', 'ab6cd'))
     self.assertFalse(globs.does_glob_match('ab*[!4-7]cd', 'ab6cd'))
Exemplo n.º 6
0
 def test_range_matches(self):
     self.assertTrue(globs.does_glob_match('ab[a-z]cd', 'abgcd'))
     self.assertTrue(globs.does_glob_match('ab[a-z]cd', 'abacd'))
     self.assertTrue(globs.does_glob_match('ab[a-z]cd', 'abzcd'))
     self.assertTrue(globs.does_glob_match('ab[n]cd', 'abncd'))
     self.assertTrue(globs.does_glob_match('ab[f-i]cd', 'abhcd'))
     self.assertTrue(globs.does_glob_match('ab[f-i]cd', 'abfcd'))
     self.assertTrue(globs.does_glob_match('ab[f-i]cd', 'abicd'))
     self.assertTrue(globs.does_glob_match('ab[0-9]cd', 'ab3cd'))
     self.assertTrue(globs.does_glob_match('ab[0-9]cd', 'ab0cd'))
     self.assertTrue(globs.does_glob_match('ab[0-9]cd', 'ab9cd'))
     self.assertTrue(globs.does_glob_match('ab[2-6]cd', 'ab3cd'))
     self.assertTrue(globs.does_glob_match('ab[2-6]cd', 'ab2cd'))
     self.assertTrue(globs.does_glob_match('ab[2-6]cd', 'ab6cd'))
     self.assertTrue(globs.does_glob_match('ab[fd-kt]cd', 'abfcd'))
     self.assertTrue(globs.does_glob_match('ab[fd-kt]cd', 'abhcd'))
     self.assertTrue(globs.does_glob_match('ab[fd-kt]cd', 'abtcd'))
     self.assertTrue(globs.does_glob_match('ab[A-Z]cd', 'abNcd'))
     self.assertTrue(globs.does_glob_match('ab[A-Z]cd', 'abAcd'))
     self.assertTrue(globs.does_glob_match('ab[A-Z]cd', 'abZcd'))
     self.assertTrue(globs.does_glob_match('ab[F]cd', 'abFcd'))
     self.assertTrue(globs.does_glob_match('ab[!4-7]cd', 'ab3cd'))
     self.assertTrue(globs.does_glob_match('ab[!4-7]cd', 'ab8cd'))
     self.assertTrue(globs.does_glob_match('ab[!4-7]cd', 'ab0cd'))
     self.assertTrue(globs.does_glob_match('ab[!4-7]cd', 'abtcd'))
     self.assertTrue(globs.does_glob_match('ab[!4-7]cd', 'abrcd'))
     self.assertTrue(globs.does_glob_match('ab[!4-7]cd', 'abKcd'))
     self.assertTrue(globs.does_glob_match('ab[!4-7]cd', 'ab.cd'))
     self.assertTrue(globs.does_glob_match('ab*[2-6]cd', 'ab3cd'))
     self.assertTrue(globs.does_glob_match('ab*[2-6]cd', 'abeothtn3cd'))
     self.assertTrue(globs.does_glob_match('ab*[2-6]cd', 'abe45363cd'))
     self.assertTrue(globs.does_glob_match('ab*[!4-7]cd', 'ab.cd'))
     self.assertTrue(globs.does_glob_match('ab*[!4-7]cd', 'abtheto.cd'))
     self.assertTrue(globs.does_glob_match('ab*[!4-7]cd', 'ab4536.cd'))
Exemplo n.º 7
0
 def test_simple_non_matches(self):
     self.assertFalse(globs.does_glob_match('*abcd', 'bcd'))
     self.assertFalse(globs.does_glob_match('ab*cd', 'acd'))
     self.assertFalse(globs.does_glob_match('ab*cd', 'abd'))
     self.assertFalse(globs.does_glob_match('abcd*', 'abc'))
     self.assertFalse(globs.does_glob_match('ab?cd', 'abcd'))
     self.assertFalse(globs.does_glob_match('ab?cd', 'acd'))
     self.assertFalse(globs.does_glob_match('abcd?', 'abcd'))
     self.assertFalse(globs.does_glob_match('abcd*?', 'abcd'))
     self.assertFalse(globs.does_glob_match('abcd?*', 'abcd'))
     self.assertFalse(globs.does_glob_match('abcd*?*', 'abcd'))
     self.assertFalse(globs.does_glob_match('a[acd]cd', 'abcd'))
     self.assertFalse(globs.does_glob_match('a[!b]cd', 'abcd'))
     self.assertFalse(globs.does_glob_match('a[!abcd]cd', 'abcd'))
     self.assertFalse(globs.does_glob_match('ab[,]cd', 'ab.cd'))
     self.assertFalse(globs.does_glob_match('ab[!,]cd', 'ab,cd'))
     self.assertFalse(globs.does_glob_match('ab[ab,(]cd', 'ab.cd'))
     self.assertFalse(globs.does_glob_match('a*[acd]cd', 'abcd'))
     self.assertFalse(globs.does_glob_match('a*[acd]cd', 'athtnbcd'))
     self.assertFalse(globs.does_glob_match('a*[acd]cd', 'aaccabcd'))
     self.assertFalse(globs.does_glob_match('ab*[!,]cd', 'ab,cd'))
     self.assertFalse(globs.does_glob_match('ab*[!,]cd', 'abtht,cd'))
     self.assertFalse(globs.does_glob_match('ab*[!,]cd', 'ab,,,,cd'))