eliot
eliot copied to clipboard
validate_logging interacts badly with trial-based, Deferred-returning tests that fail with SkipTest
This is like #153 but for the case where the test uses Twisted, returns a Deferred, and the Deferred fires with SkipTest:
from eliot.testing import assertHasAction, validate_logging
from eliot import Action
from twisted.trial.unittest import SkipTest, TestCase
from twisted.internet.defer import fail
class LogTests(TestCase):
@validate_logging(
lambda case, logger:
assertHasAction(case, logger, Action, succeeded=True)
)
def test_log(self, logger):
return fail(SkipTest("Oops"))
$ trial it.py
it
LogTests
test_log ... [SKIPPED]
[ERROR]
===============================================================================
[SKIPPED]
Oops
it.LogTests.test_log
===============================================================================
[ERROR]
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 139, in maybeDeferred
result = f(*args, **kw)
File "/usr/lib/python2.7/dist-packages/twisted/trial/_asynctest.py", line 273, in <lambda>
return lambda: f(*args, **kwargs)
File "/home/jean-paul/Projects/eliot/master/eliot/testing.py", line 270, in <lambda>
self, logger, *assertionArgs, **assertionKwargs))
File "/home/jean-paul/Projects/eliot/master/it.py", line 8, in <lambda>
@validate_logging(lambda case, logger: assertHasAction(case, logger, Action, succeeded=True))
File "/home/jean-paul/Projects/eliot/master/eliot/testing.py", line 354, in assertHasAction
testCase.assertTrue(actions, "No actions of type %s" % (actionType,))
File "/usr/lib/python2.7/dist-packages/twisted/trial/_synctest.py", line 308, in assertTrue
raise self.failureException(msg)
twisted.trial.unittest.FailTest: No actions of type <class 'eliot._action.Action'>
it.LogTests.test_log
-------------------------------------------------------------------------------
Ran 1 tests in 0.013s
FAILED (skips=1, errors=1)