/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_lazy_regex.py

  • Committer: Martin
  • Date: 2018-11-16 19:09:31 UTC
  • mfrom: (7175 work)
  • mto: This revision was merged to the branch mainline in revision 7177.
  • Revision ID: gzlist@googlemail.com-20181116190931-rmh7pk2an1zuecby
Merge trunk to resolve conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
    def test_invalid_pattern(self):
32
32
        error = lazy_regex.InvalidPattern('Bad pattern msg.')
33
33
        self.assertEqualDiff("Invalid pattern(s) found. Bad pattern msg.",
34
 
            str(error))
 
34
                             str(error))
35
35
 
36
36
 
37
37
class InstrumentedLazyRegex(lazy_regex.LazyRegex):
71
71
        self.assertEqual([('created regex', 'foo'),
72
72
                          ('__getattr__', 'match'),
73
73
                          ('_real_re_compile', ('foo',), {}),
74
 
                         ], actions)
 
74
                          ], actions)
75
75
 
76
76
    def test_bad_pattern(self):
77
77
        """Ensure lazy regex handles bad patterns cleanly."""
78
78
        p = lazy_regex.lazy_compile('RE:[')
79
79
        # As p.match is lazy, we make it into a lambda so its handled
80
80
        # by assertRaises correctly.
81
 
        e = self.assertRaises(lazy_regex.InvalidPattern, lambda: p.match('foo'))
 
81
        e = self.assertRaises(lazy_regex.InvalidPattern,
 
82
                              lambda: p.match('foo'))
82
83
        # Expect either old or new form of error message
83
84
        self.assertContainsRe(e.msg, '^"RE:\\[" '
84
 
            '(unexpected end of regular expression'
85
 
            '|unterminated character set at position 3)$')
 
85
                              '(unexpected end of regular expression'
 
86
                              '|unterminated character set at position 3)$')
86
87
 
87
88
 
88
89
class TestLazyCompile(tests.TestCase):
133
134
        lazy_pattern = lazy_regex.lazy_compile('[,;]+')
134
135
        pickled = pickle.dumps(lazy_pattern)
135
136
        unpickled_lazy_pattern = pickle.loads(pickled)
136
 
        self.assertEqual(['x', 'y', 'z'],
137
 
            unpickled_lazy_pattern.split('x,y;z'))
 
137
        self.assertEqual(
 
138
            ['x', 'y', 'z'], unpickled_lazy_pattern.split('x,y;z'))