~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: Martin Pool
  • Date: 2010-07-15 09:47:16 UTC
  • mfrom: (5345 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5346.
  • Revision ID: mbp@canonical.com-20100715094716-sljdg6go0d12xi79
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
from bzrlib import (
29
29
    errors,
 
30
    lazy_regex,
30
31
    osutils,
 
32
    symbol_versioning,
31
33
    tests,
32
34
    trace,
33
35
    win32utils,
1705
1707
 
1706
1708
class TestReCompile(tests.TestCase):
1707
1709
 
 
1710
    def _deprecated_re_compile_checked(self, *args, **kwargs):
 
1711
        return self.applyDeprecated(symbol_versioning.deprecated_in((2, 2, 0)),
 
1712
            osutils.re_compile_checked, *args, **kwargs)
 
1713
 
1708
1714
    def test_re_compile_checked(self):
1709
 
        r = osutils.re_compile_checked(r'A*', re.IGNORECASE)
 
1715
        r = self._deprecated_re_compile_checked(r'A*', re.IGNORECASE)
1710
1716
        self.assertTrue(r.match('aaaa'))
1711
1717
        self.assertTrue(r.match('aAaA'))
1712
1718
 
1713
1719
    def test_re_compile_checked_error(self):
1714
1720
        # like https://bugs.launchpad.net/bzr/+bug/251352
 
1721
 
 
1722
        # Due to possible test isolation error, re.compile is not lazy at
 
1723
        # this point. We re-install lazy compile.
 
1724
        lazy_regex.install_lazy_compile()
1715
1725
        err = self.assertRaises(
1716
1726
            errors.BzrCommandError,
1717
 
            osutils.re_compile_checked, '*', re.IGNORECASE, 'test case')
 
1727
            self._deprecated_re_compile_checked, '*', re.IGNORECASE, 'test case')
1718
1728
        self.assertEqual(
1719
 
            "Invalid regular expression in test case: '*': "
1720
 
            "nothing to repeat",
 
1729
            'Invalid regular expression in test case: '
 
1730
            '"*" nothing to repeat',
1721
1731
            str(err))
1722
1732
 
1723
1733