summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGael Pasgrimaud <gael@gawel.org>2012-12-06 03:35:42 +0100
committerGael Pasgrimaud <gael@gawel.org>2012-12-06 03:35:42 +0100
commitbb2dbe2815b3792c2d104635254a7e4624c8c8bf (patch)
tree02b0c35b8407bb41b7edfe294807381d736d3de5
parent994b7d1041ef158693e19740b1a284e0fde6a346 (diff)
downloadwebtest-bb2dbe2815b3792c2d104635254a7e4624c8c8bf.tar.gz
moar six
-rw-r--r--webtest/compat.py46
1 files changed, 8 insertions, 38 deletions
diff --git a/webtest/compat.py b/webtest/compat.py
index d960633..d495dd2 100644
--- a/webtest/compat.py
+++ b/webtest/compat.py
@@ -4,20 +4,18 @@ import six
from six import PY3
from six import text_type
from six import binary_type
+from six import string_types
from six.moves import http_client
+from six.moves import http_cookies
from six.moves import BaseHTTPServer
from six.moves import SimpleHTTPServer
+from six.moves import cStringIO
+from json import loads
+from json import dumps
-try:
- from json import loads
- from json import dumps
-except ImportError:
- try:
- from simplejson import loads
- from simplejson import dumps
- except ImportError:
- loads = None
- dumps = None
+StringIO = BytesIO = cStringIO # Also define BytesIO for py2.x
+SimpleCookie = http_cookies.SimpleCookie
+CookieError = http_cookies.CookieError
def to_bytes(value, charset='latin1'):
@@ -27,31 +25,19 @@ def to_bytes(value, charset='latin1'):
if PY3:
- string_types = (str,)
from html.entities import name2codepoint
- from io import StringIO
from io import BytesIO
from urllib.parse import urlencode
from urllib.parse import splittype
from urllib.parse import splithost
import urllib.parse as urlparse
- from http.cookies import SimpleCookie, CookieError
from http.cookies import _quote as cookie_quote
-
-
else:
- string_types = basestring
from htmlentitydefs import name2codepoint
from urllib import splittype
from urllib import splithost
from urllib import urlencode
- from Cookie import SimpleCookie, CookieError
from Cookie import _quote as cookie_quote
- try:
- from cStringIO import StringIO
- except ImportError:
- from StringIO import StringIO
- BytesIO = StringIO
import urlparse
@@ -68,19 +54,3 @@ try:
from collections import OrderedDict
except ImportError:
OrderedDict = dict
-
-try:
- from unittest import TestCase
- from unittest import skipIf
-except ImportError:
- try:
- from unittest2 import TestCase
- from unittest2 import skipIf
- except ImportError:
- from unittest import TestCase
- def skipIf(condition, message):
- if condition:
- return None
- def wrapper(func):
- return func
- return wrapper