~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_lazy_regex.py

  • Committer: Jelmer Vernooij
  • Date: 2012-02-20 12:19:29 UTC
  • mfrom: (6437.23.11 2.5)
  • mto: (6581.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6582.
  • Revision ID: jelmer@samba.org-20120220121929-7ni2psvjoatm1yp4
Merge bzr/2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Test that lazy regexes are not compiled right away"""
18
18
 
 
19
import pickle
19
20
import re
20
21
 
21
22
from bzrlib import errors
115
116
        pattern = lazy_regex.lazy_compile('[,;]*')
116
117
        self.assertEqual(['x', 'y', 'z'], pattern.split('x,y;z'))
117
118
 
 
119
    def test_pickle(self):
 
120
        # When pickling, just compile the regex.
 
121
        # Sphinx, which we use for documentation, pickles
 
122
        # some compiled regexes.
 
123
        lazy_pattern = lazy_regex.lazy_compile('[,;]*')
 
124
        pickled = pickle.dumps(lazy_pattern)
 
125
        unpickled_lazy_pattern = pickle.loads(pickled)
 
126
        self.assertEqual(['x', 'y', 'z'],
 
127
            unpickled_lazy_pattern.split('x,y;z'))
 
128
 
118
129
 
119
130
class TestInstallLazyCompile(tests.TestCase):
120
131
    """Tests for lazy compiled regexps.