Ian Lewis avatar Ian Lewis committed 4c74ec3

Added tox.ini for running tests using tox.

Comments (0)

Files changed (4)

 *.pyc
 *.swp
 *.egg-info
+.tox
 build
 dist
 docs/ja/build

beproud/django/ssl/tests/base.py

 
 from urlparse import urlsplit, urlunsplit
 
-from django.core import exceptions
-from django.utils.importlib import import_module
-from django.test import TestCase as DjangoTestCase
-from django.http import HttpRequest, HttpResponse, QueryDict
+from django.http import QueryDict
 from django.conf import settings as django_settings
 
 from beproud.django.ssl.conf import settings
 class FlatpageTests(object):
     def setUp(self):
         super(FlatpageTests,self).setUp()
-        import os
         from django.contrib.flatpages.models import FlatPage
         from django.contrib.sites.models import Site
 
-        self._old_TEMPLATE_DIRS = django_settings.TEMPLATE_DIRS
-        django_settings.TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), 'templates'),)
         django_settings.MIDDLEWARE_CLASSES += (
             'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
         )
         )
         fp.sites.add(Site.objects.get_current())
 
-    def tearDown(self):
-        super(FlatpageTests,self).tearDown()
-        django_settings.TEMPLATE_DIRS = self._old_TEMPLATE_DIRS
-
     def test_http_flatpage_http(self):
         self.assertContains(self.get('/flatpage/'), 'Non-secure Flatpage')
 
     os.environ["DJANGO_SETTINGS_MODULE"] = "django.conf.global_settings"
     from django.conf import global_settings
 
+    global_settings.SECRET_KEY = "snakeoil"
+    global_settings.TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__),
+                                      'beproud', 'django', 'ssl', 'tests', 'templates'),)
+
     global_settings.INSTALLED_APPS = (
         'django.contrib.auth',
         'django.contrib.contenttypes',
     )
     global_settings.SITE_ID=1
     global_settings.ROOT_URLCONF='beproud.django.ssl.tests.urls'
-    global_settings.DATABASE_ENGINE = "sqlite3"
-    global_settings.DATABASE_NAME = ":memory:"
+    global_settings.DATABASES = {
+        'default': {
+            'ENGINE': 'django.db.backends.sqlite3',
+            'NAME': ':memory:',
+        }
+    }
+
     global_settings.SSL_URLS = (
         '^/sslurl/',
     )
     from django.test.utils import get_runner
     test_runner = get_runner(global_settings)
 
-    if django.VERSION > (1,2):
-        test_runner = test_runner()
-        failures = test_runner.run_tests(['ssl'])
-    else:
-        failures = test_runner(['ssl'], verbosity=1)
+    test_runner = test_runner()
+    failures = test_runner.run_tests(['ssl'])
     sys.exit(failures)
 
 if __name__ == '__main__':
+# content of: tox.ini , put in same dir as setup.py
+[tox]
+envlist = django12,django13,django14,django15
+
+[testenv:django12]
+deps=
+    django==1.2.7
+commands=python setup.py test
+
+[testenv:django13]
+deps=
+    django==1.3.4
+commands=python setup.py test
+
+[testenv:django14]
+deps=
+    django==1.4.2
+commands=python setup.py test
+
+[testenv:django15]
+deps=
+    https://www.djangoproject.com/download/1.5a1/tarball/ 
+commands=python setup.py test
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.