Question

Here's a gist: https://gist.github.com/pconerly/e07ba1294266b38c6a5a

All of the files are in the same directory. I'm on python 2.7.2 and my pip freeze > reqs.txt is in the gist.

I came across with problem while trying to use AsyncHTTPTestCase and it's self.fetch() function. It's not clear to me which __init__ is being called incorrectly.

Here's the stacktrace:

(smokesignal)peterconerly$ python runtest.py 

Debug app 0.1.0
-------------- Running Test Suite --------------

<unittest.suite.TestSuite tests=[<unittest.suite.TestSuite tests=[<unittest.suite.TestSuite tests=[]>, <unittest.suite.TestSuite tests=[]>, <unittest.suite.TestSuite tests=[<test.TestDebug testMethod=test_foo>]>]>]>
E
======================================================================
ERROR: test_foo (test.TestDebug)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/peterconerly/code/tornado_debug/test.py", line 13, in test_foo
    response = self.fetch('/foo')
  File "/Users/peterconerly/.virtualenvs/smokesignal/lib/python2.7/site-packages/tornado/testing.py", line 333, in fetch
    return self.wait()
  File "/Users/peterconerly/.virtualenvs/smokesignal/lib/python2.7/site-packages/tornado/testing.py", line 272, in wait
    self.__rethrow()
  File "/Users/peterconerly/.virtualenvs/smokesignal/lib/python2.7/site-packages/tornado/testing.py", line 208, in __rethrow
    raise_exc_info(failure)
  File "/Users/peterconerly/.virtualenvs/smokesignal/lib/python2.7/site-packages/tornado/stack_context.py", line 302, in wrapped
    ret = fn(*args, **kwargs)
  File "/Users/peterconerly/.virtualenvs/smokesignal/lib/python2.7/site-packages/tornado/httpserver.py", line 328, in _on_headers
    self.request_callback(self._request)
TypeError: __init__() takes exactly 1 argument (2 given)

----------------------------------------------------------------------
Ran 1 test in 0.011s

FAILED (errors=1)
[E 140512 10:36:30 testing:614] FAIL
(smokesignal)peterconerly$ 

I'm wondering if my DebugApp needs to have an init argument for a callback method? I haven't seen that pattern in any of the examples I've looked at.

Was it helpful?

Solution

I suspect the get_app method should return a class instance. If you look at the example provided in the documentation, it returns an instance of tornado.web.Application:

def get_app(self):
    return Application([('/', MyHandler)...])

But you return a type:

def get_app(self):
    return DebugApp

What you probably want is:

def get_app(self):
    return DebugApp()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top