diff options
| author | Gael Pasgrimaud <gael@gawel.org> | 2011-08-23 23:21:55 +0200 |
|---|---|---|
| committer | Gael Pasgrimaud <gael@gawel.org> | 2011-08-23 23:21:55 +0200 |
| commit | e80b2c880a8703c3ffa3f612943443ab64c70c4d (patch) | |
| tree | b022f675c61620af85c6bdf221947cf6893bc963 /webtest/compat.py | |
| parent | e3d3201e334b1114f71374b5898317ca1f1c3721 (diff) | |
| download | webtest-e80b2c880a8703c3ffa3f612943443ab64c70c4d.tar.gz | |
more python3 support
Diffstat (limited to 'webtest/compat.py')
| -rw-r--r-- | webtest/compat.py | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/webtest/compat.py b/webtest/compat.py index 9f1f05b..f12e86a 100644 --- a/webtest/compat.py +++ b/webtest/compat.py @@ -3,27 +3,33 @@ import sys if sys.version_info[0] > 2: PY3 = True - class Base(object): - def __init__(self, content_type='text/html', *args, **kwargs): - self.content_type = content_type - self.charset = self.body = self.url = None - self.request = None - class Request(Base): - def __init__(self, *args, **kwargs): - Base.__init__(self, *args, **kwargs) - self.request = Base() - Response = Request + string_types = (str,) + text_type = str + binary_type = bytes DictType = dict StringType = bytes TupleType = tuple ListType = list from io import StringIO + from urllib.parse import urlencode import urllib.parse as urlparse + from http.client import HTTPConnection + from http.client import CannotSendRequest + from http.server import HTTPServer + from http.server import SimpleHTTPRequestHandler from http.cookies import SimpleCookie, CookieError from http.cookies import _quote as cookie_quote else: PY3 = False + string_types = basestring + text_type = unicode + binary_type = str from types import DictType, StringType, TupleType, ListType + from urllib import urlencode + from httplib import HTTPConnection + from httplib import CannotSendRequest + from BaseHTTPServer import HTTPServer + from SimpleHTTPServer import SimpleHTTPRequestHandler from Cookie import SimpleCookie, CookieError from Cookie import _quote as cookie_quote try: @@ -32,6 +38,8 @@ else: from StringIO import StringIO import urlparse + + def print_stderr(value): if PY3: exec('print(value, file=sys.stderr)') |
