twisted / twisted

Event-driven networking engine written in Python.
https://twisted.org
Other
5.59k stars 1.17k forks source link

trial bombs completely when a test method calls reactor.stop() #11046

Open twisted-trac opened 18 years ago

twisted-trac commented 18 years ago
exarkun's avatar @exarkun reported
Trac ID trac#1523
Type defect
Created 2006-03-01 16:57:23Z

Here's a test case which triggers this:

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

class ReactoStopTestCase(unittest.TestCase):
    def testReactorStop(self):
        reactor.callLater(1, lambda: reactor.stop())
        return defer.Deferred()

Here's the output I get:

#!sh
exarkun@kunai:~$ trial test_reactorstop.py 
Running 1 tests.
test_reactorstop
  ReactoStopTestCase
    testReactorStop ...     cleanup errors                                           [ERROR]

/home/exarkun/Projects/Twisted/trunk/twisted/trial/reporter.py:154: twisted.trial.reporter.BrokenTestCaseWarning: REACTOR UNCLEAN! traceback(s) follow: 
  File "/home/exarkun/Projects/Twisted/trunk/twisted/trial/util.py", line 101, in _dispatch
    getattr(self, "do_%s" % attr)()
  File "/home/exarkun/Projects/Twisted/trunk/twisted/trial/util.py", line 128, in do_cleanPending
    raise PendingTimedCallsError(s)
twisted.trial.util.PendingTimedCallsError: pendingTimedCalls still pending (consider setting twisted.internet.base.DelayedCall.debug = True): <DelayedCall -1216885332 [118.999278069s] called=0 cancelled=0 onTimeout(<Deferred at 0xB777CD8CL>)>

Traceback (most recent call last):
  File "/home/exarkun/Projects/Twisted/trunk/bin/trial", line 24, in ?
    run()
  File "/home/exarkun/Projects/Twisted/trunk/twisted/scripts/trial.py", line 373, in run
    test_result = trialRunner.run(suite)
  File "/home/exarkun/Projects/Twisted/trunk/twisted/trial/runner.py", line 472, in run
    suite.run(result)
  File "/home/exarkun/Projects/Twisted/trunk/twisted/trial/runner.py", line 179, in run
    TestSuite.run(self, result)
  File "/home/exarkun/Projects/Twisted/trunk/twisted/trial/runner.py", line 119, in run
    test(result)
  File "/home/exarkun/Projects/Twisted/trunk/twisted/trial/runner.py", line 111, in __call__
    return self.run(result)
  File "/home/exarkun/Projects/Twisted/trunk/twisted/trial/runner.py", line 119, in run
    test(result)
  File "/home/exarkun/Projects/Twisted/trunk/twisted/trial/runner.py", line 111, in __call__
    return self.run(result)
  File "/home/exarkun/Projects/Twisted/trunk/twisted/trial/runner.py", line 119, in run
    test(result)
  File "/home/exarkun/Projects/Twisted/trunk/twisted/trial/runner.py", line 111, in __call__
    return self.run(result)
  File "/home/exarkun/Projects/Twisted/trunk/twisted/trial/runner.py", line 119, in run
    test(result)
  File "/home/exarkun/Projects/Twisted/trunk/twisted/trial/unittest.py", line 343, in __call__
    return self.run(*args, **kwargs)
  File "/home/exarkun/Projects/Twisted/trunk/twisted/trial/unittest.py", line 477, in run
    self._wait(d)
  File "/home/exarkun/Projects/Twisted/trunk/twisted/trial/unittest.py", line 593, in _wait
    raise KeyboardInterrupt()
KeyboardInterrupt
exarkun@kunai:~$

Note that this is without ever hitting ^C.

Searchable metadata ``` trac-id__1523 1523 type__defect defect reporter__exarkun exarkun priority__normal normal milestone__ branch__ branch_author__ status__new new resolution__None None component__trial trial keywords__ time__1141232243000000 1141232243000000 changetime__1366514255000000 1366514255000000 version__ owner__ ```
twisted-trac commented 13 years ago
Automation's avatar Automation removed owner
twisted-trac commented 18 years ago
jml's avatar @jml set status to assigned

It'd really help if you could describe what you expect to see instead.

twisted-trac commented 18 years ago
jml's avatar @jml set status to new
twisted-trac commented 11 years ago
Julian's avatar @Julian commented

Think this should be handled partially when #10915 is done.

twisted-trac commented 17 years ago
exarkun's avatar @exarkun commented

The important missing information is the test run summary. Since calling reactor.stop() in a test method is deprecated now and will presumably begin raising an exception at some future point, I would expect the test which does this to at least incur an error in the final report. The important point is that the final report must be made, even if there is a test which is buggy in this manner.