~certify-web-dev/twisted/certify-trunk

« back to all changes in this revision

Viewing changes to twisted/trial/test/test_assertions.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-01-17 14:52:35 UTC
  • mfrom: (1.1.5 upstream) (2.1.2 etch)
  • Revision ID: james.westby@ubuntu.com-20070117145235-btmig6qfmqfen0om
Tags: 2.5.0-0ubuntu1
New upstream version, compatible with python2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import StringIO
2
2
 
3
 
from twisted.python import reflect
 
3
from twisted.python import reflect, failure
4
4
from twisted.python.util import dsu
5
5
from twisted.internet import defer
6
6
from twisted.trial import unittest, runner, reporter
273
273
                       lambda x: x.trap(self.failureException))
274
274
        return d
275
275
 
 
276
    def test_assertFailure_moreInfo(self):
 
277
        """In the case of assertFailure failing, check that we get lots of
 
278
        information about the exception that was raised.
 
279
        """
 
280
        try:
 
281
            1/0
 
282
        except ZeroDivisionError:
 
283
            f = failure.Failure()
 
284
            d = defer.fail(f)
 
285
        d = self.assertFailure(d, RuntimeError)
 
286
        d.addErrback(self._checkInfo, f)
 
287
        return d
 
288
 
 
289
    def _checkInfo(self, assertionFailure, f):
 
290
        assert assertionFailure.check(self.failureException)
 
291
        output = assertionFailure.getErrorMessage()
 
292
        self.assertIn(f.getErrorMessage(), output)
 
293
        self.assertIn(f.getBriefTraceback(), output)
 
294
 
276
295
    def test_assertFailure_masked(self):
277
296
        """A single wrong assertFailure should fail the whole test.
278
297
        """