'The application object is invoked and iterated in a thread which is not
the reactor thread.'

def test_applicationCalledInThread(self):

    self.enableThreads()
    invoked = []
    def applicationFactory():
        def application(environ, startResponse):
            def result():
                for i in range(3):
                    invoked.append(getThreadID())
                    (yield intToBytes(i))
            invoked.append(getThreadID())
            startResponse('200    OK', [('content-length', '3')])
            return result()
        return application
    (d, requestFactory) = self.requestFactoryFactory()
    def cbRendered(ignored):
        self.assertNotIn(getThreadID(), invoked)
        self.assertEqual(len(set(invoked)), 1)
    d.addCallback(cbRendered)
    self.lowLevelRender(requestFactory, applicationFactory, DummyChannel, 'GET', '1.1', [], [''])
    return d
