Rev 2832: Update test for report_exception to be cleaner and work with new run_bzr behavior in http://sourcefrog.net/bzr/test-traceback
Martin Pool
mbp at sourcefrog.net
Tue Sep 18 06:40:10 BST 2007
At http://sourcefrog.net/bzr/test-traceback
------------------------------------------------------------
revno: 2832
revision-id: mbp at sourcefrog.net-20070918054009-ftyrlbde4dmzi40t
parent: mbp at sourcefrog.net-20070918053531-hwrmyg05y3az3xcx
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: test-traceback
timestamp: Tue 2007-09-18 15:40:09 +1000
message:
Update test for report_exception to be cleaner and work with new run_bzr behavior
modified:
bzrlib/tests/blackbox/test_exceptions.py test_exceptions.py-20060604211237-yi2cxg0ose3xk4id-1
=== modified file 'bzrlib/tests/blackbox/test_exceptions.py'
--- a/bzrlib/tests/blackbox/test_exceptions.py 2007-06-26 20:32:49 +0000
+++ b/bzrlib/tests/blackbox/test_exceptions.py 2007-09-18 05:40:09 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006 Canonical Ltd
+# Copyright (C) 2006, 2007 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -16,27 +16,34 @@
"""Tests for display of exceptions."""
+from cStringIO import StringIO
import os
import sys
-from bzrlib import bzrdir, repository
+from bzrlib import (
+ bzrdir,
+ repository,
+ trace,
+ )
from bzrlib.tests import TestCaseInTempDir, TestCase
from bzrlib.errors import NotBranchError
+
class TestExceptionReporting(TestCase):
def test_report_exception(self):
"""When an error occurs, display bug report details to stderr"""
- out, err = self.run_bzr("assert-fail", retcode=3)
- self.assertContainsRe(err,
- r'bzr: ERROR: exceptions\.AssertionError: always fails\n')
- self.assertContainsRe(err, r'please send this report to')
-
- # TODO: assert-fail doesn't need to always be present; we could just
- # register (and unregister) it from tests that want to touch it.
- #
- # TODO: Some kind of test for the feature of invoking pdb
+ try:
+ raise AssertionError("failed")
+ except AssertionError, e:
+ erf = StringIO()
+ trace.report_exception(sys.exc_info(), erf)
+ err = erf.getvalue()
+ self.assertContainsRe(err,
+ r'bzr: ERROR: exceptions\.AssertionError: failed\n')
+ self.assertContainsRe(err,
+ r'please send this report to')
class TestDeprecationWarning(TestCaseInTempDir):
More information about the bazaar-commits
mailing list