Carl Meyer avatar Carl Meyer committed 8e600e6

Dropped support for Django 1.0 and Python 2.4.

Comments (0)

Files changed (2)

localeurl/tests/test_utils.py

 Test utilities.
 
 """
+try:
+    from cStringIO import StringIO
+except ImportError:
+    from StringIO import StringIO
 
 from django.conf import settings as django_settings
 from django.core.handlers.wsgi import WSGIRequest
 
 
 
+class FakePayload(object):
+    """
+    A wrapper around StringIO that restricts what can be read since data from
+    the network can't be seeked and cannot be read outside of its content
+    length. This makes sure that views can't do anything under the test client
+    that wouldn't work in Real Life.
+    """
+    def __init__(self, content):
+        self.__content = StringIO(content)
+        self.__len = len(content)
+
+    def read(self, num_bytes=None):
+        if num_bytes is None:
+            num_bytes = self.__len or 0
+        assert self.__len >= num_bytes, "Cannot read more than the available bytes from the HTTP incoming data."
+        content = self.__content.read(num_bytes)
+        self.__len -= num_bytes
+        return content
+
+
 class RequestFactory(Client):
     """
     Class that lets you create mock Request objects for use in testing.
             'SERVER_NAME': 'testserver',
             'SERVER_PORT': 80,
             'SERVER_PROTOCOL': 'HTTP/1.1',
+            'wsgi.version':      (1,0),
+            'wsgi.url_scheme':   'http',
+            'wsgi.input':        FakePayload(''),
+            'wsgi.errors':       self.errors,
+            'wsgi.multiprocess': True,
+            'wsgi.multithread':  False,
+            'wsgi.run_once':     False,
         }
         environ.update(self.defaults)
         environ.update(request)
 [tox]
-envlist=py24-1.0,py24-1.1,py24-1.2,py25-1.0,py25-1.1,py25-1.2,py25,py25-trunk,py26-1.0,py26-1.1,py26-1.2,py26,py26-trunk,py27-1.0,py27-1.1,py27-1.2,py27,py27-trunk
+envlist=py25-1.1,py25-1.2,py25,py25-trunk,py26-1.1,py26-1.2,py26,py26-trunk,py27-1.1,py27-1.2,py27,py27-trunk
 
 [testenv]
 deps=
   django==1.3.1
 commands=python setup.py test
 
-[testenv:py24-1.0]
-basepython=python2.4
-deps=
-  django==1.0.4
-  pysqlite==2.6.3
-
-[testenv:py24-1.1]
-basepython=python2.4
-deps=
-  django==1.1.4
-  pysqlite==2.6.3
-
-[testenv:py24-1.2]
-basepython=python2.4
-deps=
-  django==1.2.7
-  pysqlite==2.6.3
-
-[testenv:py25-1.0]
-basepython=python2.5
-deps=
-  django==1.0.4
-
 [testenv:py25-1.1]
 basepython=python2.5
 deps=
 [testenv:py25-trunk]
 basepython=python2.5
 deps=
-  svn+http://code.djangoproject.com/svn/django/trunk#egg=django
-
-[testenv:py26-1.0]
-basepython=python2.6
-deps=
-  django==1.0.4
+  https://github.com/django/django/tarball/master
 
 [testenv:py26-1.1]
 basepython=python2.6
 [testenv:py26-trunk]
 basepython=python2.6
 deps=
-  svn+http://code.djangoproject.com/svn/django/trunk#egg=django
-
-[testenv:py27-1.0]
-basepython=python2.7
-deps=
-  django==1.0.4
+  https://github.com/django/django/tarball/master
 
 [testenv:py27-1.1]
 basepython=python2.7
 [testenv:py27-trunk]
 basepython=python2.7
 deps=
-  svn+http://code.djangoproject.com/svn/django/trunk#egg=django
+  https://github.com/django/django/tarball/master
+
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.