Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #70 (closed defect: duplicate)

Opened 14 years ago

Last modified 12 years ago

AttributeError when testing controller methods

Reported by: anonymous Owned by: anonymous
Priority: normal Milestone: 0.9
Component: TurboGears Version: 0.8
Severity: normal Keywords:
Cc:

Description

Error when testing controller methods

The test -


from turbogears.tests import util from testtest.controllers import Root import cherrypy

def test_indextitle():

"Index method should return a title"

cherrypy.root = Root() output = util.call(cherrypy.root.index) assert outputtitle? == "Foobar" assert output.has_key("now")

def test_processedTemplate():

"Index teamplate on its way out" cherrypy.root = Root() util.createRequest("/") assert "<TITLE>Foobar</TITLE>" in cherrypy.response.body[0]


and the traceback -

running build_ext Index method should return a title (testtest.tests.test_controllers) ... ERROR Index teamplate on its way out (testtest.tests.test_controllers) ... 2005/10/24 23:43:44 HTTP INFO 1 - GET / HTTP/1.1 setting default site 2005-10-24 23:43:45,212 turbogears.view DEBUG Recompiling template for testtest.templates.welcome 2005-10-24 23:43:45,324 turbogears.view DEBUG Applying template testtest.templates.welcome localhost - - [2005/10/24 23:43:45] "GET / HTTP/1.1" 200 1567 ok

====================================================================== ERROR: Index method should return a title (testtest.tests.test_controllers)


Traceback (most recent call last):

File "/usr/lib/python2.4/site-packages/TestGears-0.2-py2.4.egg/testgears/collector.py", line 26, in runTest File "/home/mattc/turbo/testtest/testtest/tests/test_controllers.py", line 9, in test_indextitle

output = util.call(cherrypy.root.index)

File "/usr/lib/python2.4/site-packages/TurboGears-0.8a3-py2.4.egg/turbogears/tests/util.py", line 25, in call

return method(*args, kw)

File "/usr/lib/python2.4/site-packages/TurboGears-0.8a3-py2.4.egg/turbogears/controllers.py", line 98, in newfunc

cherrypy.response.headerMapContent-Type?= content_type

File "/usr/lib/python2.4/site-packages/CherryPy-2.1.0_rc2-py2.4.egg/cherrypy/init.py", line 69, in getattr

childobject = getattr(serving, self.attrname)

AttributeError?: 'thread._local' object has no attribute 'response'


Ran 2 tests in 0.574s

FAILED (errors=1)

Attachments

hack.txt Download (1.3 KB) - added by anonymous 14 years ago.
workaround/hack to get testgears to work with controllers

Change History

comment:1 Changed 14 years ago by kevin

  • Component changed from CherryPy to TurboGears
  • Milestone set to 0.9

Changed 14 years ago by anonymous

workaround/hack to get testgears to work with controllers

comment:2 Changed 14 years ago by anonymous

I added a quick hack (hack.txt) to workaround this problem. On my setup using svn rev 293, it allows the usual python setup.py testgears to work properly with controller tests. I have no idea if this will be useful as an actual fix, but it does help me write/run some tests in the meantime.

comment:3 Changed 14 years ago by kevin

  • Status changed from new to closed
  • Resolution set to duplicate

As a matter of course, I try not to change the code under test for the sake of testing.

I hadn't put the two together, but ticket #181 is effectively a dupe of this one. However, that ticket as the solution for this one, so I'm going to close this ticket in favor of #181.

Note: See TracTickets for help on using tickets.