Commits

jayd3e committed bc889df

Fixd the test_call_WSGI_app test in test_request.py

  • Participants
  • Parent commits 5254e98

Comments (0)

Files changed (3)

File tests/test_request.py

         req = Request.blank('/')
         def wsgi_app(environ, start_response):
             start_response('200 OK', [('Content-type', 'text/plain')])
-            return ['Hi!']
+            return [b'Hi!']
         self.assertEqual(req.call_application(wsgi_app),
-                         ('200 OK', [('Content-type', 'text/plain')], ['Hi!']))
+                         ('200 OK', [('Content-type', 'text/plain')], [b'Hi!']))
 
         res = req.get_response(wsgi_app)
         from webob.response import Response
         from webob.headers import ResponseHeaders
         self.assertTrue(isinstance(res.headers, ResponseHeaders))
         self.assertEqual(res.headers.items(), [('Content-type', 'text/plain')])
-        self.assertEqual(res.body, 'Hi!')
+        self.assertEqual(res.body, b'Hi!')
 
     def equal_req(self, req):
         input = StringIO(str(req))

File webob/acceptparse.py

 
     def __nonzero__(self):
         return False
+    
+    __bool__ = __nonzero__
 
     def __add__(self, item):
         if isinstance(item, self.MasterClass):

File webob/response.py

                  **kw):
         if app_iter is None:
             if body is None:
-                body = ''
+                body = b''
         elif body is not None:
             raise TypeError(
                 "You may only give one of the body and app_iter arguments")
         if status is None:
-            self._status = b'200 OK'
+            self._status = '200 OK'
         else:
             self.status = status
         if headerlist is None:
                 body = body.encode(charset)
             self._body = body
             if headerlist is None:
-                self._headerlist.append((b'Content-Length', six.binary_type(len(body))))
+                self._headerlist.append(('Content-Length', str(len(body))))
             else:
-                self.headers[b'Content-Length'] = six.binary_type(len(body))
+                self.headers['Content-Length'] = str(len(body))
             self._app_iter = None
         for name, value in _iteritems(kw):
             if not hasattr(self.__class__, name):
         return self._status
 
     def _status__set(self, value):
-        if isinstance(value, six.text_type):
+        if isinstance(value, bytes):
             # Status messages have to be ASCII safe, so this is OK:
-            value = value.encode('utf-8')
+            value = value.decode('UTF-8')
         if isinstance(value, int):
-            value = value.encode('utf-8')
-        if not isinstance(value, six.binary_type):
+            value = str(value)
+        if not isinstance(value, str):
             raise TypeError(
                 "You must set status to a string or integer (not %s)"
                 % type(value))
-        if b' ' not in value:
+        if ' ' not in value:
             # Need to add a reason:
             code = int(value)
             reason = status_reasons[code]