/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 bzrlib/tests/test_globbing.py

  • Committer: Gordon Tyler
  • Date: 2009-11-11 21:38:02 UTC
  • mto: This revision was merged to the branch mainline in revision 4801.
  • Revision ID: gordon@doxxx.net-20091111213802-wj8d2fgirjd7saqn
Fixed globbing.normalize_pattern to not strip '/' down to '' and normalize multiple slashes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
from bzrlib.globbing import (
19
19
    Globster,
20
20
    _OrderedGlobster,
 
21
    normalize_pattern
21
22
    )
22
23
from bzrlib.tests import (
23
24
    TestCase,
318
319
        globster = _OrderedGlobster(reversed(patterns))
319
320
        self.assertEqual(u'bar.*', globster.match('bar.foo'))
320
321
        self.assertEqual(None, globster.match('foo.bar'))
 
322
 
 
323
 
 
324
class TestNormalizePattern(TestCase):
 
325
 
 
326
    def test_backslashes(self):
 
327
        """tests that backslashes are converted to forward slashes, multiple
 
328
        backslashes are collapsed to single forward slashes and trailing
 
329
        backslashes are removed"""
 
330
        self.assertEqual(u'/', normalize_pattern(u'\\'))
 
331
        self.assertEqual(u'/', normalize_pattern(u'\\\\'))
 
332
        self.assertEqual(u'/foo/bar', normalize_pattern(u'\\foo\\bar'))
 
333
        self.assertEqual(u'foo/bar', normalize_pattern(u'foo\\bar\\'))
 
334
        self.assertEqual(u'/foo/bar', normalize_pattern(u'\\\\foo\\\\bar\\\\'))
 
335
 
 
336
    def test_forward_slashes(self):
 
337
        """tests that multiple foward slashes are collapsed to single forward
 
338
        slashes and trailing forward slashes are removed"""
 
339
        self.assertEqual(u'/', normalize_pattern(u'/'))
 
340
        self.assertEqual(u'/', normalize_pattern(u'//'))
 
341
        self.assertEqual(u'/foo/bar', normalize_pattern(u'/foo/bar'))
 
342
        self.assertEqual(u'foo/bar', normalize_pattern(u'foo/bar/'))
 
343
        self.assertEqual(u'/foo/bar', normalize_pattern(u'//foo//bar//'))
 
344
 
 
345
    def test_mixed_slashes(self):
 
346
        """tests that multiple mixed slashes are collapsed to single forward
 
347
        slashes and trailing mixed slashes are removed"""
 
348
        self.assertEqual(u'/foo/bar', normalize_pattern(u'\\/\\foo//\\///bar/\\\\/'))