diff options
| author | Michael Merickel <michael@merickel.org> | 2014-03-24 23:00:42 -0500 |
|---|---|---|
| committer | Michael Merickel <michael@merickel.org> | 2014-03-24 23:00:42 -0500 |
| commit | 6fadce6b810276522fc420e0ec10fe40fd607538 (patch) | |
| tree | edbfbdc0fefaaca7b401f580d24c4077034211dc | |
| parent | fc86aa2c3ce80460f8ec4bd49153540054191dd6 (diff) | |
| parent | a99abf808a15fbc02da4c27ab7d46d03668b62ed (diff) | |
| download | pyramid-6fadce6b810276522fc420e0ec10fe40fd607538.tar.gz pyramid-6fadce6b810276522fc420e0ec10fe40fd607538.tar.bz2 pyramid-6fadce6b810276522fc420e0ec10fe40fd607538.zip | |
Merge pull request #1269 from msabramo/test_unicode_in_url
Add integration tests for Unicode in URL
| -rw-r--r-- | pyramid/tests/test_integration.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/pyramid/tests/test_integration.py b/pyramid/tests/test_integration.py index 9d3a9e004..35648ed38 100644 --- a/pyramid/tests/test_integration.py +++ b/pyramid/tests/test_integration.py @@ -640,6 +640,48 @@ class RendererScanAppTest(IntegrationBase, unittest.TestCase): res = testapp.get('/two', status=200) self.assertTrue(b'Two!' in res.body) +class UnicodeInURLTest(unittest.TestCase): + def _makeConfig(self): + from pyramid.config import Configurator + config = Configurator() + return config + + def _makeTestApp(self, config): + from webtest import TestApp + app = config.make_wsgi_app() + return TestApp(app) + + def test_unicode_in_url_404(self): + request_path = '/avalia%C3%A7%C3%A3o_participante' + request_path_unicode = b'/avalia\xc3\xa7\xc3\xa3o_participante'.decode('utf-8') + + config = self._makeConfig() + testapp = self._makeTestApp(config) + + res = testapp.get(request_path, status=404) + + # Pyramid default 404 handler outputs: + # u'404 Not Found\n\nThe resource could not be found.\n\n\n' + # u'/avalia\xe7\xe3o_participante\n\n' + self.assertTrue(request_path_unicode in res.text) + + def test_unicode_in_url_200(self): + request_path = '/avalia%C3%A7%C3%A3o_participante' + request_path_unicode = b'/avalia\xc3\xa7\xc3\xa3o_participante'.decode('utf-8') + + def myview(request): + return 'XXX' + + config = self._makeConfig() + config.add_route('myroute', request_path_unicode) + config.add_view(myview, route_name='myroute', renderer='json') + testapp = self._makeTestApp(config) + + res = testapp.get(request_path, status=200) + + self.assertEqual(res.text, '"XXX"') + + class AcceptContentTypeTest(unittest.TestCase): def setUp(self): def hello_view(request): |
