~ubuntu-branches/debian/sid/bzr/sid

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_lazy_regex.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij, Jelmer Vernooij, Max Bowsher
  • Date: 2011-07-14 15:35:42 UTC
  • mfrom: (1.5.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20110714153542-7m3m8jpt6c167g2a
Tags: 2.4.0~beta5-1
[ Jelmer Vernooij ]
* Fix typo in package description. Thanks Paul Stewart.
* Mark python-bzrlib as breaking with older versions of bzr that
  predate python-bzrlib. LP: #803362

[ Max Bowsher ]
* New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006, 2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
41
41
    def _real_re_compile(self, *args, **kwargs):
42
42
        self._actions.append(('_real_re_compile',
43
43
                                               args, kwargs))
44
 
        return super(InstrumentedLazyRegex, self)._real_re_compile(*args, **kwargs)
 
44
        return super(InstrumentedLazyRegex, self)._real_re_compile(
 
45
            *args, **kwargs)
45
46
 
46
47
 
47
48
class TestLazyRegex(tests.TestCase):
116
117
 
117
118
 
118
119
class TestInstallLazyCompile(tests.TestCase):
 
120
    """Tests for lazy compiled regexps.
119
121
 
120
 
    def setUp(self):
121
 
        super(TestInstallLazyCompile, self).setUp()
122
 
        self.addCleanup(lazy_regex.reset_compile)
 
122
    Other tests, and bzrlib in general, count on the lazy regexp compiler
 
123
    being installed, and this is done by loading bzrlib.  So these tests
 
124
    assume it is installed, and leave it installed when they're done.
 
125
    """
123
126
 
124
127
    def test_install(self):
 
128
        # Don't count on it being present
125
129
        lazy_regex.install_lazy_compile()
126
130
        pattern = re.compile('foo')
127
131
        self.assertIsInstance(pattern, lazy_regex.LazyRegex)
128
132
 
129
133
    def test_reset(self):
130
 
        lazy_regex.install_lazy_compile()
131
134
        lazy_regex.reset_compile()
 
135
        self.addCleanup(lazy_regex.install_lazy_compile)
132
136
        pattern = re.compile('foo')
133
137
        self.assertFalse(isinstance(pattern, lazy_regex.LazyRegex),
134
 
                    'lazy_regex.reset_compile() did not restore the original'
135
 
                    ' compile() function %s' % (type(pattern),))
 
138
            'lazy_regex.reset_compile() did not restore the original'
 
139
            ' compile() function %s' % (type(pattern),))
136
140
        # but the returned object should still support regex operations
137
141
        m = pattern.match('foo')
138
142
        self.assertEqual('foo', m.group())