/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/test_globbing.py

  • Committer: Jelmer Vernooij
  • Date: 2018-05-06 11:48:54 UTC
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@jelmer.uk-20180506114854-h4qd9ojaqy8wxjsd
Move .mailmap to root.

Show diffs side-by-side

added added

removed removed

Lines of Context:
264
264
        self.assertMatch([
265
265
            (u'*.x',
266
266
             [u'foo/bar/baz.x', u'\u8336/Q.x', u'foo.y.x', u'.foo.x',
267
 
              u'bar/.foo.x', u'.x', ],
 
267
              u'bar/.foo.x', u'.x',],
268
268
             [u'foo.x.y']),
269
269
            (u'foo/*.bar',
270
270
             [u'foo/b.bar', u'foo/a.b.bar', u'foo/.bar'],
289
289
 
290
290
        The types being extension, basename and full path.
291
291
        """
292
 
        patterns = [u'*.foo', u'.*.swp', u'./*.png']
 
292
        patterns = [ u'*.foo', u'.*.swp', u'./*.png']
293
293
        globster = Globster(patterns)
294
294
        self.assertEqual(u'*.foo', globster.match('bar.foo'))
295
295
        self.assertEqual(u'./*.png', globster.match('foo.png'))
318
318
        g = Globster(patterns)
319
319
        e = self.assertRaises(lazy_regex.InvalidPattern, g.match, 'filename')
320
320
        self.assertContainsRe(e.msg,
321
 
                              r"File.*ignore.*contains error.*RE:\[.*RE:\*\.cpp", flags=re.DOTALL)
 
321
            r"File.*ignore.*contains error.*RE:\[.*RE:\*\.cpp", flags=re.DOTALL)
322
322
 
323
323
 
324
324
class TestExceptionGlobster(TestCase):
325
325
 
326
326
    def test_exclusion_patterns(self):
327
327
        """test that exception patterns are not matched"""
328
 
        patterns = [u'*', u'!./local', u'!./local/**/*',
329
 
                    u'!RE:\\.z.*', u'!!./.zcompdump']
 
328
        patterns = [ u'*', u'!./local', u'!./local/**/*', u'!RE:\\.z.*', u'!!./.zcompdump' ]
330
329
        globster = ExceptionGlobster(patterns)
331
330
        self.assertEqual(u'*', globster.match('tmp/foo.txt'))
332
331
        self.assertEqual(None, globster.match('local'))
337
336
 
338
337
    def test_exclusion_order(self):
339
338
        """test that ordering of exclusion patterns does not matter"""
340
 
        patterns = [u'static/**/*.html', u'!static/**/versionable.html']
 
339
        patterns = [ u'static/**/*.html', u'!static/**/versionable.html']
341
340
        globster = ExceptionGlobster(patterns)
342
 
        self.assertEqual(u'static/**/*.html',
343
 
                         globster.match('static/foo.html'))
 
341
        self.assertEqual(u'static/**/*.html', globster.match('static/foo.html'))
344
342
        self.assertEqual(None, globster.match('static/versionable.html'))
345
343
        self.assertEqual(None, globster.match('static/bar/versionable.html'))
346
344
        globster = ExceptionGlobster(reversed(patterns))
347
 
        self.assertEqual(u'static/**/*.html',
348
 
                         globster.match('static/foo.html'))
 
345
        self.assertEqual(u'static/**/*.html', globster.match('static/foo.html'))
349
346
        self.assertEqual(None, globster.match('static/versionable.html'))
350
347
        self.assertEqual(None, globster.match('static/bar/versionable.html'))
351
348
 
352
 
 
353
349
class TestOrderedGlobster(TestCase):
354
350
 
355
351
    def test_ordered_globs(self):
356
352
        """test that the first match in a list is the one found"""
357
 
        patterns = [u'*.foo', u'bar.*']
 
353
        patterns = [ u'*.foo', u'bar.*']
358
354
        globster = _OrderedGlobster(patterns)
359
355
        self.assertEqual(u'*.foo', globster.match('bar.foo'))
360
356
        self.assertEqual(None, globster.match('foo.bar'))
387
383
    def test_mixed_slashes(self):
388
384
        """tests that multiple mixed slashes are collapsed to single forward
389
385
        slashes and trailing mixed slashes are removed"""
390
 
        self.assertEqual(
391
 
            u'/foo/bar', normalize_pattern(u'\\/\\foo//\\///bar/\\\\/'))
 
386
        self.assertEqual(u'/foo/bar', normalize_pattern(u'\\/\\foo//\\///bar/\\\\/'))