Opened 10 years ago

#5792 defect new

reactor.callWhenRunning should cause a DirtyReactorError in trial, if the reactor isn't started during the test.

Reported by: Tom Prince Owned by:
Priority: normal Milestone:
Component: trial Keywords:
Cc: Jonathan Lange Branch:


The following code reports an error in test_2 when the error is actually in test_1

from twisted.internet import defer, task
from twisted.internet import reactor
from twisted.trial import unittest

class Test(unittest.TestCase):
    def test_1(self):
        def cb():
            task.LoopingCall(lambda: None).start(1)
    def test_2(self):
        d = defer.Deferred()
        reactor.callLater(0.1, d.callback, None)
        return d

trial output:

    test_1 ...                                                             [OK]
    test_2 ...                                                          [ERROR]

Traceback (most recent call last):
Failure: twisted.trial.util.DirtyReactorAggregateError: Reactor was unclean.
DelayedCalls: (set twisted.internet.base.DelayedCall.debug = True to debug)
<DelayedCall 0x2b4efc8 [0.898566961288s] called=0 cancelled=0 LoopingCall<1>(<lambda>, *(), **{})()>

Ran 2 tests in 0.107s

FAILED (errors=1, successes=1

Change History (1)

comment:1 Changed 10 years ago by DefaultCC Plugin

Cc: Jonathan Lange added
Note: See TracTickets for help on using tickets.