Skip to content
Browse files

- Applying #2294 to this branch hopefully the last patch!

  • Loading branch information...
1 parent 41b20af commit 6ff0f42f6cab37bfd1e0b239f04d99cbe6d2a3fe @elpargo elpargo committed May 24, 2009
Showing with 25 additions and 1 deletion.
  1. +1 −0 setup.py
  2. +2 −1 tg/controllers/decoratedcontroller.py
  3. +22 −0 tg/tests/test_tg_controller_dispatch.py
View
1 setup.py
@@ -17,6 +17,7 @@
'chameleon.genshi',
'repoze.what >= 1.0.5',
'repoze.who-testutil >= 1.0rc1',
+ 'wsgiref',
]
setup(
View
3 tg/controllers/decoratedcontroller.py
@@ -74,7 +74,8 @@ def _call(self, controller, params, remainder=None):
remainder = remainder or []
try:
- pylons.request.headers['tg_format'] = params.get('tg_format', None)
+ if 'tg_format' in params:
+ pylons.request.headers['tg_format'] = params['tg_format']
controller.decoration.run_hooks('before_validate', remainder,
params)
View
22 tg/tests/test_tg_controller_dispatch.py
@@ -13,6 +13,9 @@
from tg.tests.base import TestWSGIController, make_app, setup_session_dir, \
teardown_session_dir
+from wsgiref.simple_server import demo_app
+from wsgiref.validate import validator
+
def setup():
setup_session_dir()
def teardown():
@@ -262,6 +265,25 @@ def test_not_found_unicode(self):
r = self.app.get('/права', status=404)
assert '404 Not Found' in r, r
+class TestWSGIAppController(TestWSGIController):
+ def __init__(self, *args, **kargs):
+ TestWSGIController.__init__(self, *args, **kargs)
+ class TestedWSGIAppController(WSGIAppController):
+ def __init__(self):
+ def test_app(environ, start_response):
+ if environ['CONTENT_LENGTH'] in (-1, '-1'):
+ del environ['CONTENT_LENGTH']
+ return validator(demo_app)(environ, start_response)
+ super(TestedWSGIAppController, self).__init__(test_app)
+ self.app = make_app(TestedWSGIAppController)
+
+ def test_valid_wsgi(self):
+ try:
+ r = self.app.get('/some_url')
+ except Exception, e:
+ raise AssertionError(str(e))
+ assert 'some_url' in r
+
class TestTGController(TestWSGIController):
def __init__(self, *args, **kargs):
TestWSGIController.__init__(self, *args, **kargs)

0 comments on commit 6ff0f42

Please sign in to comment.
Something went wrong with that request. Please try again.