Commits

Mikhail Korobov committed ab930d6

WebTest 2.0 compatibility. Fix #4.

Comments (0)

Files changed (4)

django_webtest/__init__.py

     from django.contrib.staticfiles.handlers import StaticFilesHandler
 
 from webtest import TestApp
-from webtest.compat import to_string
 
 from django_webtest.response import DjangoWebtestResponse
+from django_webtest.compat import to_string
 
 
 class DjangoTestApp(TestApp):

django_webtest/compat.py

+import sys
+
+PY3 = sys.version_info[0] == 3
+
+if PY3:
+    def to_string(s):
+        if isinstance(s, str):
+            return s
+        return str(s, 'latin1')
+
+    from urllib import parse as urlparse
+
+else:
+
+    def to_string(s):
+        return str(s)
+
+    import urlparse
+

django_webtest/response.py

 # -*- coding: utf-8 -*-
-
-try:
-    import urlparse
-except ImportError: #python 3
-    from urllib import parse as urlparse
-
-from webtest import TestResponse
 from django.test import Client
 from django.http import SimpleCookie
-
+from webtest import TestResponse
+from django_webtest.compat import urlparse
 
 class DjangoWebtestResponse(TestResponse):
     """
 [tox]
-envlist = py26,py27,pypy,dj12,dj13,dj14,dj15,dj15-py32,dj15-py33,dj15-py33-postgres
+envlist =
+    py26,py27,pypy,
+    dj12,dj13,dj14,dj15,
+    dj15-py32,dj15-py33,dj15-py33-postgres,
+    py26-wt1x, py32-wt2x
 
 [testenv]
+basepython = python2.7
 deps=
     WebTest
     django
 commands=
     python django_webtest_tests/runtests.py []
 
+[testenv:py26]
+basepython = python2.6
+
+[testenv:pypy]
+basepython = pypy
+
+
 [testenv:dj12]
 deps=
     WebTest
 [testenv:dj13]
 deps=
     WebTest
-    django == 1.3.5
+    django == 1.3.7
 
 [testenv:dj14]
 deps=
     WebTest
-    django == 1.4.3
+    django == 1.4.5
 
 [django15]
 deps=
-    git+https://github.com/django/django.git@64f1a175bd8228493ef600a62cd2f331a17787e6#egg=django
+    django == 1.5
 
 [testenv:dj15]
 deps=
     {[testenv:dj15]deps}
 basepython = python3.3
 
+[testenv:py26-wt1x]
+basepython = python2.6
+deps =
+    WebTest < 2.0
+    django
+
+[testenv:py32-wt2x]
+basepython = python3.2
+deps =
+    WebTest >= 2.0
+    django
 
 
 ; In order to run tests for this environment,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.