~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2008-09-09 15:09:12 UTC
  • mto: This revision was merged to the branch mainline in revision 3699.
  • Revision ID: john@arbash-meinel.com-20080909150912-wyttm8he1zsls2ck
Use the right timing function on win32

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""Tests for display of exceptions."""
18
18
 
33
33
 
34
34
class TestExceptionReporting(TestCase):
35
35
 
 
36
    def test_report_exception(self):
 
37
        """When an error occurs, display bug report details to stderr"""
 
38
        try:
 
39
            raise AssertionError("failed")
 
40
        except AssertionError, e:
 
41
            erf = StringIO()
 
42
            trace.report_exception(sys.exc_info(), erf)
 
43
        err = erf.getvalue()
 
44
        self.assertContainsRe(err,
 
45
            r'bzr: ERROR: exceptions\.AssertionError: failed\n')
 
46
        self.assertContainsRe(err,
 
47
            r'Please report a bug at https://bugs\.launchpad\.net/bzr/\+filebug')
 
48
        self.assertContainsRe(err,
 
49
            '(?m)^encoding: .*, fsenc: .*, lang: .*')
 
50
        self.assertContainsRe(err,
 
51
            '(?m)^plugins:$')
 
52
 
36
53
    def test_exception_exitcode(self):
37
54
        # we must use a subprocess, because the normal in-memory mechanism
38
55
        # allows errors to propagate up through the test suite
41
58
            retcode=errors.EXIT_INTERNAL_ERROR)
42
59
        self.assertEqual(4, errors.EXIT_INTERNAL_ERROR)
43
60
        self.assertContainsRe(err,
44
 
                r'exceptions\.AssertionError: always fails\n')
45
 
        self.assertContainsRe(err, r'Bazaar has encountered an internal error')
46
 
 
 
61
                r'bzr: ERROR: exceptions\.AssertionError: always fails\n')
 
62
        self.assertContainsRe(err, r'Please report a bug at')
 
63
    
47
64
 
48
65
class TestDeprecationWarning(TestCaseInTempDir):
49
66