13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
"""Tests for display of exceptions."""
34
34
class TestExceptionReporting(TestCase):
36
def test_report_exception(self):
37
"""When an error occurs, display bug report details to stderr"""
39
raise AssertionError("failed")
40
except AssertionError, e:
42
trace.report_exception(sys.exc_info(), erf)
44
self.assertContainsRe(err,
45
r'bzr: ERROR: exceptions\.AssertionError: failed\n')
46
self.assertContainsRe(err,
47
r'Please send this report to')
48
self.assertContainsRe(err,
49
'(?m)^encoding: .*, fsenc: .*, lang: .*')
50
self.assertContainsRe(err,
53
36
def test_exception_exitcode(self):
54
37
# we must use a subprocess, because the normal in-memory mechanism
55
38
# allows errors to propagate up through the test suite
56
39
out, err = self.run_bzr_subprocess(['assert-fail'],
40
universal_newlines=True,
57
41
retcode=errors.EXIT_INTERNAL_ERROR)
58
42
self.assertEqual(4, errors.EXIT_INTERNAL_ERROR)
59
43
self.assertContainsRe(err,
60
r'bzr: ERROR: exceptions\.AssertionError: always fails\n')
61
self.assertContainsRe(err, r'Please send this report to')
44
r'exceptions\.AssertionError: always fails\n')
45
self.assertContainsRe(err, r'Bazaar has encountered an internal error')
64
48
class TestDeprecationWarning(TestCaseInTempDir):