From 55fb96a0411d5a2b14360ce075eb9e087aedc310 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sat, 24 Sep 2011 04:44:02 -0400 Subject: fix all request tests except the ones which invoke call_app_with_subpath --- pyramid/request.py | 4 ++-- pyramid/tests/test_request.py | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pyramid/request.py b/pyramid/request.py index cfab88860..6b77b09e9 100644 --- a/pyramid/request.py +++ b/pyramid/request.py @@ -11,8 +11,8 @@ from pyramid.interfaces import ISessionFactory from pyramid.interfaces import IResponseFactory from pyramid.compat import json -from pyramid.compat import native_ from pyramid.compat import iterkeys_, itervalues_, iteritems_ +from pyramid.compat import text_ from pyramid.exceptions import ConfigurationError from pyramid.decorator import reify from pyramid.response import Response @@ -362,7 +362,7 @@ class Request(BaseRequest, DeprecatedRequestMethodsMixin, URLMethodsMixin, @property def json_body(self): - return json.loads(self.body, encoding=self.charset) + return json.loads(text_(self.body, self.charset)) def route_request_iface(name, bases=()): # zope.interface treats the __name__ as the __doc__ and changes __name__ diff --git a/pyramid/tests/test_request.py b/pyramid/tests/test_request.py index 2dadb7d52..c731edb7f 100644 --- a/pyramid/tests/test_request.py +++ b/pyramid/tests/test_request.py @@ -2,6 +2,8 @@ import unittest from pyramid import testing from pyramid.compat import text_ +from pyramid.compat import bytes_ +from pyramid.compat import iteritems_, iterkeys_, itervalues_ class TestRequest(unittest.TestCase): def setUp(self): @@ -52,7 +54,7 @@ class TestRequest(unittest.TestCase): } request = self._makeOne(environ) request.charset = None - self.assertEqual(request.GET['la'], text_('La Pe\xf1a')) + self.assertEqual(request.GET['la'], text_(b'La Pe\xf1a')) def test_class_implements(self): from pyramid.interfaces import IRequest @@ -249,8 +251,8 @@ class TestRequest(unittest.TestCase): from pyramid.compat import json request = self._makeOne({'REQUEST_METHOD':'POST'}) request.charset = 'latin-1' - la = text_('La Pe\xc3\xb1a', 'utf-8') - body = json.dumps({'a':la}, encoding='latin-1') + la = text_(b'La Pe\xc3\xb1a', 'utf-8') + body = bytes_(json.dumps({'a':la}), 'latin-1') request.body = body self.assertEqual(request.json_body, {'a':la}) @@ -324,17 +326,17 @@ class TestRequestDeprecatedMethods(unittest.TestCase): def test_iteritems(self): environ = {'zooma':1} inst = self._makeOne(environ) - self.assertEqual(list(inst.iteritems()), list(environ.iteritems())) + self.assertEqual(list(inst.iteritems()), list(iteritems_(environ))) def test_iterkeys(self): environ = {'zooma':1} inst = self._makeOne(environ) - self.assertEqual(list(inst.iterkeys()), list(environ.iterkeys())) + self.assertEqual(list(inst.iterkeys()), list(iterkeys_(environ))) def test_itervalues(self): environ = {'zooma':1} inst = self._makeOne(environ) - self.assertEqual(list(inst.itervalues()), list(environ.itervalues())) + self.assertEqual(list(inst.itervalues()), list(itervalues_(environ))) def test_keys(self): environ = {'zooma':1} -- cgit v1.2.3