Opened 2 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: jml Branch:
Author: Launchpad Bug:

Description

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)
        reactor.callWhenRunning(cb)
    def test_2(self):
        d = defer.Deferred()
        reactor.callLater(0.1, d.callback, None)
        return d

trial output:

test
  Test
    test_1 ...                                                             [OK]
    test_2 ...                                                          [ERROR]

===============================================================================
[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>, *(), **{})()>

test.Test.test_2
-------------------------------------------------------------------------------
Ran 2 tests in 0.107s

FAILED (errors=1, successes=1

Change History (1)

comment:1 Changed 2 years ago by DefaultCC Plugin

  • Cc jml added
Note: See TracTickets for help on using tickets.