Bug #1819078 “Asynchronously supercalling setUp or tearDown fail...” : Bugs : testtools (original) (raw)

I expected this would be a valid test case:

```
from testtools import TestCase
from testtools.twistedsupport import AsynchronousDeferredRunTest
from twisted.internet.defer import Deferred

class X(TestCase):
run_tests_with = AsynchronousDeferredRunTest

def setUp(self):
d = Deferred()
d.addCallback(lambda ignored: super(X, self).setUp())
self.reactor.callLater(0.0, d.callback, None)
return d

def test_foo(self):
pass
```

However, it fails:

```
===============================================================================
[ERROR]
Traceback (most recent call last):
Failure: testtools.testresult.real._StringException: Empty attachments:
twisted-log

traceback-1: {{{
Traceback (most recent call last):
File "/home/exarkun/Environments/tahoe-lafs/local/lib/python2.7/site-packages/testtools/twistedsupport/_runtest.py", line 386, in _log_user_exception
raise e
testtools.twistedsupport._runtest.UncleanReactorError: The reactor still thinks it needs to do things. Close all connections, kill all processes and make sure all delayed calls have either f
ired or been cancelled:
<DelayedCall 0x7fc94d489ab8 [-0.00155591964722s] called=0 cancelled=1>
}}}

Traceback (most recent call last):
File "/home/exarkun/Environments/tahoe-lafs/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 151, in maybeDeferred
result = f(*args, **kw)
File "/home/exarkun/Environments/tahoe-lafs/local/lib/python2.7/site-packages/testtools/testcase.py", line 688, in _run_setup
self.__class__.__name__))
ValueError: In File: /tmp/asyncfixture.py
TestCase.setUp was not called. Have you upcalled all the way up the hierarchy from your setUp? e.g. Call super(X, self).setUp() from your setUp().

asyncfixture.X.test_foo
-------------------------------------------------------------------------------
```

The check for upcalling happens synchronously and independent of the Twisted support being applied.