Opened 4 years ago

Last modified 4 years ago

#9266 enhancement new

trial should mark logged but unflushed errors as such

Reported by: mark williams Owned by:
Priority: normal Milestone:
Component: trial Keywords:
Cc: Allison Kaptur Branch:


trial reports logged failures that were not flushed with flushLoggedErrors as a test failure. Unfortunately it doesn't indicate that these failures were logged, leading to confusing test output.


from twisted.trial import unittest
from twisted.logger import Logger
from twisted.python.failure import Failure

class UnderTest(object):
    log = Logger()

    def method(self):
            raise Exception
            self.log.failure("what", failure=Failure())

class ExampleTest(unittest.SynchronousTestCase):

    def test_logging(self):

trial's output indicates a failure:

    test_logging ...                                                    [ERROR]

Traceback (most recent call last):
  File "/path/to/", line 11, in method
    raise Exception

Ran 1 tests in 0.123s
FAILED (errors=1)

The output does not indicate that it's an unflushed, logged exception, since it only includes the ERROR status and a traceback. This is confusing unless you're accustomed to the overly terse output.

When reporting an error that's due to an unflushed, logged exception, trial should mention as much.


Change History (2)

comment:1 Changed 4 years ago by Allison Kaptur

Cc: Allison Kaptur added

comment:2 Changed 4 years ago by Glyph

I think this may be at least tangentially related to #2365, in that it affects how Trial formats its output messages.

Note: See TracTickets for help on using tickets.