/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: 2019-06-02 02:35:46 UTC
  • mfrom: (7309 work)
  • mto: This revision was merged to the branch mainline in revision 7319.
  • Revision ID: jelmer@jelmer.uk-20190602023546-lqco868tnv26d8ow
merge trunk.

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/**/*', u'!RE:\\.z.*', u'!!./.zcompdump' ]
 
328
        patterns = [u'*', u'!./local', u'!./local/**/*',
 
329
                    u'!RE:\\.z.*', u'!!./.zcompdump']
329
330
        globster = ExceptionGlobster(patterns)
330
331
        self.assertEqual(u'*', globster.match('tmp/foo.txt'))
331
332
        self.assertEqual(None, globster.match('local'))
336
337
 
337
338
    def test_exclusion_order(self):
338
339
        """test that ordering of exclusion patterns does not matter"""
339
 
        patterns = [ u'static/**/*.html', u'!static/**/versionable.html']
 
340
        patterns = [u'static/**/*.html', u'!static/**/versionable.html']
340
341
        globster = ExceptionGlobster(patterns)
341
 
        self.assertEqual(u'static/**/*.html', globster.match('static/foo.html'))
 
342
        self.assertEqual(u'static/**/*.html',
 
343
                         globster.match('static/foo.html'))
342
344
        self.assertEqual(None, globster.match('static/versionable.html'))
343
345
        self.assertEqual(None, globster.match('static/bar/versionable.html'))
344
346
        globster = ExceptionGlobster(reversed(patterns))
345
 
        self.assertEqual(u'static/**/*.html', globster.match('static/foo.html'))
 
347
        self.assertEqual(u'static/**/*.html',
 
348
                         globster.match('static/foo.html'))
346
349
        self.assertEqual(None, globster.match('static/versionable.html'))
347
350
        self.assertEqual(None, globster.match('static/bar/versionable.html'))
348
351
 
 
352
 
349
353
class TestOrderedGlobster(TestCase):
350
354
 
351
355
    def test_ordered_globs(self):
352
356
        """test that the first match in a list is the one found"""
353
 
        patterns = [ u'*.foo', u'bar.*']
 
357
        patterns = [u'*.foo', u'bar.*']
354
358
        globster = _OrderedGlobster(patterns)
355
359
        self.assertEqual(u'*.foo', globster.match('bar.foo'))
356
360
        self.assertEqual(None, globster.match('foo.bar'))
383
387
    def test_mixed_slashes(self):
384
388
        """tests that multiple mixed slashes are collapsed to single forward
385
389
        slashes and trailing mixed slashes are removed"""
386
 
        self.assertEqual(u'/foo/bar', normalize_pattern(u'\\/\\foo//\\///bar/\\\\/'))
 
390
        self.assertEqual(
 
391
            u'/foo/bar', normalize_pattern(u'\\/\\foo//\\///bar/\\\\/'))