Bastian wrote:
> This is what I hacked so far to get my TurboGears pages tested using
> wsgi interception.
>
Thank you, I need it too..
I've just tried it but got it working for the first test method only.
I took out the DBTest part because I need to have my own
> from twill import wsgi_intercept
> from project.controllers import Root
> import cherrypy, unittest
> from turbogears import testutil
> from twill._browser import PatchedMechanizeBrowser as Browser
>
> class WSGITest(unittest.TestCase):
> def setUp(self):
> _cached_app = {}
> def get_wsgi_app(_cached_app=_cached_app):
> if not _cached_app:
> cherrypy.root = Root()
> testutil.start_cp()
> from cherrypy._cpwsgi import wsgiApp
> _cached_app['app'] = wsgiApp
> return _cached_app['app']
>
> wsgi_intercept.add_wsgi_intercept('localhost', 80, get_wsgi_app)
>
> def tearDown(self):
> wsgi_intercept.remove_wsgi_intercept('localhost', 80)
> # cherrypy.server.stop()
>
>
> class RootControllerTest(WSGITest):
>
> def test_index(self):
> b = Browser()
> b.open('http://localhost/')
>
> def test_index1(self):
> b = Browser()
> b.open('http://localhost/')
The first test method works and has the expected content. I can also
load other pages and do everything I am supposed to.
The second and subsequent methods have no such luck:
File
"/usr/lib/python2.4/site-packages/twill-0.9b1-py2.4.egg/twill/other_packages/mechanize/_mechanize.py",
line 156, in open
return self._mech_open(url, data)
File
"/usr/lib/python2.4/site-packages/twill-0.9b1-py2.4.egg/twill/other_packages/mechanize/_mechanize.py",
line 207, in _mech_open
raise response
httperror_seek_wrapper: HTTP Error 500: Internal error
Calling server.stop() makes no difference.
I guess I need to look closer at the _cached_app magic..
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---