~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_log.py

  • Committer: Guillermo Gonzalez
  • Date: 2008-03-31 03:56:49 UTC
  • mto: (3542.1.1 logdisplayers)
  • mto: This revision was merged to the branch mainline in revision 3556.
  • Revision ID: guillo.gonzo@gmail.com-20080331035649-y732vhbondfc3w6k
 * added error handling (and logging) to LogFormatter.show_properties when a handler raise an error
 * added test case for broken and missing handler

Show diffs side-by-side

added added

removed removed

Lines of Context:
187
187
        
188
188
    def test_log_with_custom_properties(self):
189
189
        tree = self._prepare()
190
 
        # add a new revision containing a custom property
191
190
        tree.commit(message='', revprops={'first_prop':'first_value'})
192
191
        
193
192
        # define a trivial custom property handler
198
197
            'trivial_custom_prop_handler', 
199
198
            trivial_custom_prop_handler)
200
199
        log = self.run_bzr("log --limit 1")[0]
201
 
        # check if it's in the output
202
200
        self.assertContainsRe(log, r'first_prop: first_value\n')
203
 
        
204
 
        log = self.run_bzr("log -r1")[0]
205
 
        # should no be any extra properties in the first revision
206
 
        self.assertNotContainsRe(log, r'first_prop: first_value\n')
 
201
        log = self.run_bzr("log -r1")[0]
 
202
        self.assertNotContainsRe(log, r'first_prop: first_value\n')
 
203
        bzrlib.log.custom_properties_handler_registry.remove(
 
204
            'trivial_custom_prop_handler')
 
205
    
 
206
    def test_log_without_custom_properties_handler(self):
 
207
        tree = self._prepare()
 
208
        tree.commit(message='', revprops={'first_prop':'first_value'})
 
209
        log = self.run_bzr("log --limit 1")[0]
 
210
        self.assertNotContainsRe(log, r'first_prop: first_value\n')
 
211
        log = self.run_bzr("log -r1")[0]
 
212
        self.assertNotContainsRe(log, r'first_prop: first_value\n')
 
213
    
 
214
    def test_log_broken_custom_properties_handler(self):
 
215
        tree = self._prepare()
 
216
        tree.commit(message='', revprops={'first_prop':'first_value'})
 
217
        
 
218
        # define a broken custom property handler
 
219
        def broken_custom_prop_handler(props_dict):
 
220
            raise errors.BzrError('a test error')
 
221
        
 
222
        bzrlib.log.custom_properties_handler_registry.register(
 
223
            'broken_custom_prop_handler', 
 
224
            broken_custom_prop_handler)
 
225
        log = self.run_bzr("log --limit 1")[0]
 
226
        self.assertNotContainsRe(log, r'first_prop: first_value\n')
 
227
        log = self.run_bzr("log -r1")[0]
 
228
        self.assertNotContainsRe(log, r'first_prop: first_value\n')
 
229
        bzr_log = self._get_log(keep_log_file=True)
 
230
        self.assertContainsRe(bzr_log, 
 
231
            "custom property handler: %s raised an error" % \
 
232
            'broken_custom_prop_handler')
 
233
        self.assertContainsRe(bzr_log, 'a test error')
 
234
        bzrlib.log.custom_properties_handler_registry.remove(
 
235
            'broken_custom_prop_handler')
 
236
 
207
237
 
208
238
class TestLogMerges(ExternalBase):
209
239