[Twisted-Python] Conch Testing server and client

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Fri Jul 1 07:21:39 MDT 2011


On 12:59 pm, anshul.singhle at gmail.com wrote:
>I understand that. The problem I'm facing is that unless I write
>"reactor.run()" my client isn't starting up. From what I understood in 
>the
>trial documentation, I should simply call the connectTCP method and 
>then
>return a deferred. However, if I do that, the client isn't starting. 
>I'll
>post some of the client code for you info :
>
>[snip]

Complicated, incomplete code snippets aren't very useful.  Always follow 
http://sscce.org/ when sharing code.  For example:

    from twisted.trial.unittest import TestCase
    from twisted.internet.defer import Deferred
    from twisted.internet import reactor

    class ReactorIsRunningTests(TestCase):
        def test_isTheReactorRunning(self):
            d = Deferred()
            reactor.callLater(1, d.callback, None)
            return d

The output I expect from this, when run with trial, is one test method 
which takes 1 second to complete, and then succeeds.  The output I get 
is:

    reactortests
      ReactorIsRunningTests
        test_isTheReactorRunning ... 
[OK]

-----------------------------------------------------------------------
    Ran 1 tests in 1.003s

    PASSED (successes=1)

In other words, it behaves as I expect.

Jean-Paul




More information about the Twisted-Python mailing list