~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_trace.py

  • Committer: Gordon Tyler
  • Date: 2010-02-25 13:15:08 UTC
  • mto: This revision was merged to the branch mainline in revision 5070.
  • Revision ID: gordon@doxxx.net-20100225131508-2ntxutul7ibo92wa
Improved test_show_error to check kwargs, dict substitution and exception handling.

Show diffs side-by-side

added added

removed removed

Lines of Context:
221
221
        show_error('error1')
222
222
        show_error(u'error2 \xb5 blah')
223
223
        show_error('arg: %s', 'blah')
 
224
        show_error('arg2: %(key)s', {'key':'stuff'})
 
225
        try:
 
226
            raise Exception("oops")
 
227
        except:
 
228
            show_error('kwarg', exc_info=True)
224
229
        log = self.get_log()
225
230
        self.assertContainsRe(log, 'error1')
226
231
        self.assertContainsRe(log, u'error2 \xb5 blah')
227
232
        self.assertContainsRe(log, 'arg: blah')
 
233
        self.assertContainsRe(log, 'arg2: stuff')
 
234
        self.assertContainsRe(log, 'kwarg')
 
235
        self.assertContainsRe(log, 'Traceback \\(most recent call last\\):')
 
236
        self.assertContainsRe(log, 'File ".*test_trace.py", line .*, in test_show_error')
 
237
        self.assertContainsRe(log, 'raise Exception\\("oops"\\)')
 
238
        self.assertContainsRe(log, 'Exception: oops')
228
239
 
229
240
    def test_push_log_file(self):
230
241
        """Can push and pop log file, and this catches mutter messages.