15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
from bzrlib import errors
21
18
from bzrlib.globbing import (
37
35
glob = glob_prefix + glob
38
36
globster = Globster([glob])
39
37
for name in positive:
40
self.assertTrue(globster.match(name), repr(
38
self.failUnless(globster.match(name), repr(
41
39
u'name "%s" does not match glob "%s" (re=%s)' %
42
40
(name, glob, globster._regex_patterns[0][0].pattern)))
43
41
for name in negative:
44
self.assertFalse(globster.match(name), repr(
42
self.failIf(globster.match(name), repr(
45
43
u'name "%s" does match glob "%s" (re=%s)' %
46
44
(name, glob, globster._regex_patterns[0][0].pattern)))
54
52
def test_char_group_digit(self):
55
53
self.assertMatchBasenameAndFullpath([
56
54
# The definition of digit this uses includes arabic digits from
57
# non-latin scripts (arabic, indic, etc.) but neither roman
58
# numerals nor vulgar fractions. Some characters such as
59
# subscript/superscript digits may or may not match depending on
60
# the Python version used, see: <http://bugs.python.org/issue6561>
55
# non-latin scripts (arabic, indic, etc.) and subscript/superscript
56
# digits, but neither roman numerals nor vulgar fractions.
62
[u'0', u'5', u'\u0663', u'\u06f9', u'\u0f21'],
58
[u'0', u'5', u'\u0663', u'\u06f9', u'\u0f21', u'\xb9'],
63
59
[u'T', u'q', u' ', u'\u8336', u'.']),
65
61
[u'T', u'q', u' ', u'\u8336', u'.'],
66
[u'0', u'5', u'\u0663', u'\u06f9', u'\u0f21']),
62
[u'0', u'5', u'\u0663', u'\u06f9', u'\u0f21', u'\xb9']),
69
65
def test_char_group_space(self):
312
308
self.assertEqual(patterns[x],globster.match(filename))
313
309
self.assertEqual(None,globster.match('foobar.300'))
315
def test_bad_pattern(self):
316
"""Ensure that globster handles bad patterns cleanly."""
317
patterns = [u'RE:[', u'/home/foo', u'RE:*.cpp']
318
g = Globster(patterns)
319
e = self.assertRaises(errors.InvalidPattern, g.match, 'filename')
320
self.assertContainsRe(e.msg,
321
"File.*ignore.*contains error.*RE:\[.*RE:\*\.cpp", flags=re.DOTALL)
324
311
class TestExceptionGlobster(TestCase):
326
313
def test_exclusion_patterns(self):