Commits

Chris McDonough committed 0266129

better py3 compat

Comments (0)

Files changed (9)

buildout-py3k.cfg

     webob
     nose
     six
+    lxml
+    PyQuery
+#    BeautifulSoup
 interpreter = python
     >>> print(form.method)
     POST
     >>> # dict of fields
-    >>> fields = form.fields.items(); fields.sort(); fields
+    >>> fields = list(form.fields.items()); fields.sort(); fields
     [(u'name', [<Text name="name">]), (u'submit', [<Submit name="submit">])]
     >>> form['name'] = 'Bob'
     >>> # When names don't point to a single field:
 
     >>> from webtest import TestRequest
     >>> from webtest import TestResponse
-    >>> res = TestResponse(content_type='text/html', body='''
+    >>> res = TestResponse(content_type='text/html', body=b'''
     ... <html><body><div id="content">hey!</div></body>''')
     >>> res.request = TestRequest.blank('/')
     >>> res.html
     >>> res.lxml.xpath('//body/div')[0].text
     'hey!'
     >>> res = TestResponse(content_type='application/json',
-    ...                    body='{"a":1,"b":2}')
+    ...                    body=b'{"a":1,"b":2}')
     >>> res.request = TestRequest.blank('/')
     >>> res.json.values()
     [1, 2]
     >>> res = TestResponse(content_type='application/xml',
-    ...                    body='<xml><message>hey!</message></xml>')
+    ...                    body=b'<xml><message>hey!</message></xml>')
     >>> res.request = TestRequest.blank('/')
     >>> res.xml
     <Element ...>

tests/test_click.py

 
 def links_app(environ, start_response):
     req = Request(environ)
-    status = to_bytes("200 OK")
+    status = "200 OK"
     responses = {
        '/': """
             <html>

tests/test_cookie.py

 
 def cookie_app(environ, start_response):
     req = Request(environ)
-    status = to_bytes("200 OK")
+    status = "200 OK"
     body = '<html><body><a href="/go/">go</a></body></html>'
     headers = [
         ('Content-Type', 'text/html'),

tests/test_file_upload.py

 
 def single_upload_file_app(environ, start_response):
     req = Request(environ)
-    status = to_bytes("200 OK")
+    status = "200 OK"
     if req.method == "GET":
         body = to_bytes(
 """
 
 def upload_binary_app(environ, start_response):
     req = Request(environ)
-    status = to_bytes("200 OK")
+    status = "200 OK"
     if req.method == "GET":
         body = to_bytes("""
 <html>
 
 def multiple_upload_file_app(environ, start_response):
     req = Request(environ)
-    status = to_bytes("200 OK")
+    status = "200 OK"
     if req.method == "GET":
         body = to_bytes(
 """

tests/test_input.py

 
 def input_app(environ, start_response):
     req = Request(environ)
-    status = to_bytes("200 OK")
+    status = "200 OK"
     body = to_bytes(
 """
 <html>
 
 def input_app_without_default(environ, start_response):
     req = Request(environ)
-    status = to_bytes("200 OK")
+    status = "200 OK"
     body = to_bytes(
 """
 <html>
 
 def input_unicode_app(environ, start_response):
     req = Request(environ)
-    status = to_bytes("200 OK")
+    status = "200 OK"
     body =\
 u("""
 <html>

tests/test_select.py

     headers = [
         ('Content-Type', 'text/html; charset=utf-8'),
         ('Content-Length', str(len(body)))]
-    start_response(to_bytes(status), headers)
+    start_response(status, headers)
     return [body]
 
 def select_app_without_default(environ, start_response):
     headers = [
         ('Content-Type', 'text/html; charset=utf-8'),
         ('Content-Length', str(len(body)))]
-    start_response(to_bytes(status), headers)
+    start_response(status, headers)
     return [body]
 
 
     headers = [
         ('Content-Type', 'text/html; charset=utf-8'),
         ('Content-Length', str(len(body)))]
-    start_response(to_bytes(status), headers)
+    start_response(status, headers)
     if not isinstance(body, binary_type):
         raise AssertionError('Body is not %s' % binary_type)
     return [body]

tests/test_selenium.py

 from webob import exc
 from tests.compat import unittest
 
+raise NotImplementedError
+
 files = os.path.dirname(__file__)
 
 def application(environ, start_response):

webtest/debugapp.py

             header_name = name[len('header-'):]
             headers.append((header_name, value))
 
-    start_response(to_bytes(str(status)), headers)
+    start_response(str(status), headers)
     if req.method == 'HEAD':
         return [to_bytes('')]
     return [body]