summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2011-08-13 13:51:34 +0000
committerJannis Leidel <jannis@leidel.info>2011-08-13 13:51:34 +0000
commita13de6cd76b12da0520ddccb2d746dd73eb70d28 (patch)
treefdf79db448b5c29d3f9638ddec07d01b705f45cc
parent566b3295fa77e9755613ac36e0d73950938cc577 (diff)
Fixed #6644 -- Fixed django.contrib.formtools tests to be better isolated when running outside of the Django test suite. Also moved around the new wizard's templates a bit to better fit the common app layout.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16616 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/formtools/templates/formtools/wizard/wizard_form.html (renamed from django/contrib/formtools/wizard/templates/formtools/wizard/wizard_form.html)0
-rw-r--r--django/contrib/formtools/tests/__init__.py34
-rw-r--r--django/contrib/formtools/tests/forms.py4
-rw-r--r--django/contrib/formtools/tests/templates/base.html2
-rw-r--r--django/contrib/formtools/tests/wizard/__init__.py17
-rw-r--r--django/contrib/formtools/tests/wizard/cookiestorage.py (renamed from django/contrib/formtools/wizard/tests/cookiestoragetests.py)3
-rw-r--r--django/contrib/formtools/tests/wizard/forms.py (renamed from django/contrib/formtools/wizard/tests/formtests.py)2
-rw-r--r--django/contrib/formtools/tests/wizard/loadstorage.py (renamed from django/contrib/formtools/wizard/tests/loadstoragetests.py)0
-rw-r--r--django/contrib/formtools/tests/wizard/namedwizardtests/__init__.py0
-rw-r--r--django/contrib/formtools/tests/wizard/namedwizardtests/forms.py (renamed from django/contrib/formtools/wizard/tests/namedwizardtests/forms.py)0
-rw-r--r--django/contrib/formtools/tests/wizard/namedwizardtests/tests.py (renamed from django/contrib/formtools/wizard/tests/namedwizardtests/tests.py)10
-rw-r--r--django/contrib/formtools/tests/wizard/namedwizardtests/urls.py (renamed from django/contrib/formtools/wizard/tests/namedwizardtests/urls.py)4
-rw-r--r--django/contrib/formtools/tests/wizard/sessionstorage.py (renamed from django/contrib/formtools/wizard/tests/sessionstoragetests.py)3
-rw-r--r--django/contrib/formtools/tests/wizard/storage.py (renamed from django/contrib/formtools/wizard/tests/storagetests.py)3
-rw-r--r--django/contrib/formtools/tests/wizard/wizardtests/__init__.py0
-rw-r--r--django/contrib/formtools/tests/wizard/wizardtests/forms.py (renamed from django/contrib/formtools/wizard/tests/wizardtests/forms.py)2
-rw-r--r--django/contrib/formtools/tests/wizard/wizardtests/templates/other_wizard_form.html (renamed from django/contrib/formtools/wizard/tests/wizardtests/templates/other_wizard_form.html)0
-rw-r--r--django/contrib/formtools/tests/wizard/wizardtests/tests.py (renamed from django/contrib/formtools/wizard/tests/wizardtests/tests.py)5
-rw-r--r--django/contrib/formtools/tests/wizard/wizardtests/urls.py (renamed from django/contrib/formtools/wizard/tests/wizardtests/urls.py)2
-rw-r--r--django/contrib/formtools/wizard/tests/__init__.py6
-rw-r--r--django/contrib/formtools/wizard/tests/namedwizardtests/__init__.py1
-rw-r--r--django/contrib/formtools/wizard/tests/wizardtests/__init__.py1
-rw-r--r--docs/ref/contrib/formtools/form-wizard.txt2
-rw-r--r--docs/ref/contrib/index.txt2
-rwxr-xr-xtests/runtests.py1
25 files changed, 60 insertions, 44 deletions
diff --git a/django/contrib/formtools/wizard/templates/formtools/wizard/wizard_form.html b/django/contrib/formtools/templates/formtools/wizard/wizard_form.html
index b98e58d1c7..b98e58d1c7 100644
--- a/django/contrib/formtools/wizard/templates/formtools/wizard/wizard_form.html
+++ b/django/contrib/formtools/templates/formtools/wizard/wizard_form.html
diff --git a/django/contrib/formtools/tests/__init__.py b/django/contrib/formtools/tests/__init__.py
index 7084386501..25a55a41b9 100644
--- a/django/contrib/formtools/tests/__init__.py
+++ b/django/contrib/formtools/tests/__init__.py
@@ -4,12 +4,13 @@ import warnings
from django import http
from django.conf import settings
-from django.contrib.formtools import preview, wizard, utils
+from django.contrib.formtools import preview, utils
+from django.contrib.formtools.wizard import FormWizard
from django.test import TestCase
from django.test.utils import get_warnings_state, restore_warnings_state
from django.utils import unittest
-from django.contrib.formtools.wizard.tests import *
+from django.contrib.formtools.tests.wizard import *
from django.contrib.formtools.tests.forms import *
warnings.filterwarnings('ignore', category=PendingDeprecationWarning,
@@ -30,10 +31,22 @@ class TestFormPreview(preview.FormPreview):
return http.HttpResponse(success_string)
-class PreviewTests(TestCase):
+class FormToolsTestCase(TestCase):
+ def setUp(self):
+ # in the test runner use templates/tests/ to provide base.html
+ self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS
+ settings.TEMPLATE_DIRS = list(settings.TEMPLATE_DIRS) + [
+ os.path.join(os.path.dirname(__file__), 'templates')]
+
+ def tearDown(self):
+ settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
+
+
+class PreviewTests(FormToolsTestCase):
urls = 'django.contrib.formtools.tests.urls'
def setUp(self):
+ super(PreviewTests, self).setUp()
self.save_warnings_state()
warnings.filterwarnings('ignore', category=DeprecationWarning,
module='django.contrib.formtools.utils')
@@ -45,6 +58,7 @@ class PreviewTests(TestCase):
self.test_data = {'field1':u'foo', 'field1_':u'asdf'}
def tearDown(self):
+ super(PreviewTests, self).tearDown()
self.restore_warnings_state()
def test_unused_name(self):
@@ -224,7 +238,7 @@ class FormHmacTests(unittest.TestCase):
# FormWizard tests
#
-class TestWizardClass(wizard.FormWizard):
+class TestWizardClass(FormWizard):
def get_template(self, step):
return 'forms/wizard.html'
@@ -243,7 +257,7 @@ class DummyRequest(http.HttpRequest):
self._dont_enforce_csrf_checks = True
-class WizardTests(TestCase):
+class WizardTests(FormToolsTestCase):
urls = 'django.contrib.formtools.tests.urls'
input_re = re.compile('name="([^"]+)" value="([^"]+)"')
wizard_step_data = (
@@ -261,19 +275,13 @@ class WizardTests(TestCase):
)
def setUp(self):
- self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS
- settings.TEMPLATE_DIRS = (
- os.path.join(
- os.path.dirname(__file__),
- 'templates'
- ),
- )
+ super(WizardTests, self).setUp()
# Use a known SECRET_KEY to make security_hash tests deterministic
self.old_SECRET_KEY = settings.SECRET_KEY
settings.SECRET_KEY = "123"
def tearDown(self):
- settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
+ super(WizardTests, self).tearDown()
settings.SECRET_KEY = self.old_SECRET_KEY
def test_step_starts_at_zero(self):
diff --git a/django/contrib/formtools/tests/forms.py b/django/contrib/formtools/tests/forms.py
index 93bad924b8..9f6f596d3c 100644
--- a/django/contrib/formtools/tests/forms.py
+++ b/django/contrib/formtools/tests/forms.py
@@ -9,10 +9,10 @@ class Page1(forms.Form):
class Page2(forms.Form):
address1 = forms.CharField(max_length=100)
address2 = forms.CharField(max_length=100)
-
+
class Page3(forms.Form):
random_crap = forms.CharField(max_length=100)
-
+
class ContactWizard(FormWizard):
def done(self, request, form_list):
return HttpResponse("")
diff --git a/django/contrib/formtools/tests/templates/base.html b/django/contrib/formtools/tests/templates/base.html
new file mode 100644
index 0000000000..c6afe66197
--- /dev/null
+++ b/django/contrib/formtools/tests/templates/base.html
@@ -0,0 +1,2 @@
+{% block content %}
+{% endblock %} \ No newline at end of file
diff --git a/django/contrib/formtools/tests/wizard/__init__.py b/django/contrib/formtools/tests/wizard/__init__.py
new file mode 100644
index 0000000000..dce2fedfe0
--- /dev/null
+++ b/django/contrib/formtools/tests/wizard/__init__.py
@@ -0,0 +1,17 @@
+from django.contrib.formtools.tests.wizard.cookiestorage import TestCookieStorage
+from django.contrib.formtools.tests.wizard.forms import FormTests, SessionFormTests, CookieFormTests
+from django.contrib.formtools.tests.wizard.loadstorage import TestLoadStorage
+from django.contrib.formtools.tests.wizard.namedwizardtests.tests import (
+ NamedSessionWizardTests,
+ NamedCookieWizardTests,
+ TestNamedUrlSessionFormWizard,
+ TestNamedUrlCookieFormWizard,
+ NamedSessionFormTests,
+ NamedCookieFormTests,
+)
+from django.contrib.formtools.tests.wizard.sessionstorage import TestSessionStorage
+from django.contrib.formtools.tests.wizard.wizardtests.tests import (
+ SessionWizardTests,
+ CookieWizardTests,
+ WizardTestKwargs,
+)
diff --git a/django/contrib/formtools/wizard/tests/cookiestoragetests.py b/django/contrib/formtools/tests/wizard/cookiestorage.py
index 74c7e822b4..495d3afd03 100644
--- a/django/contrib/formtools/wizard/tests/cookiestoragetests.py
+++ b/django/contrib/formtools/tests/wizard/cookiestorage.py
@@ -4,7 +4,8 @@ from django.core.exceptions import SuspiciousOperation
from django.http import HttpResponse
from django.contrib.formtools.wizard.storage.cookie import CookieStorage
-from django.contrib.formtools.wizard.tests.storagetests import get_request, TestStorage
+from django.contrib.formtools.tests.wizard.storage import get_request, TestStorage
+
class TestCookieStorage(TestStorage, TestCase):
def get_storage(self):
diff --git a/django/contrib/formtools/wizard/tests/formtests.py b/django/contrib/formtools/tests/wizard/forms.py
index db0aba1bff..8afbd30721 100644
--- a/django/contrib/formtools/wizard/tests/formtests.py
+++ b/django/contrib/formtools/tests/wizard/forms.py
@@ -20,6 +20,7 @@ class DummyRequest(http.HttpRequest):
self.session = {}
self._dont_enforce_csrf_checks = True
+
def get_request(*args, **kwargs):
request = DummyRequest(*args, **kwargs)
engine = import_module(settings.SESSION_ENGINE)
@@ -202,4 +203,3 @@ class CookieFormTests(TestCase):
request = get_request()
testform = CookieWizardView.as_view([('start', Step1)])
self.assertTrue(isinstance(testform(request), TemplateResponse))
-
diff --git a/django/contrib/formtools/wizard/tests/loadstoragetests.py b/django/contrib/formtools/tests/wizard/loadstorage.py
index 267dee0379..267dee0379 100644
--- a/django/contrib/formtools/wizard/tests/loadstoragetests.py
+++ b/django/contrib/formtools/tests/wizard/loadstorage.py
diff --git a/django/contrib/formtools/tests/wizard/namedwizardtests/__init__.py b/django/contrib/formtools/tests/wizard/namedwizardtests/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/django/contrib/formtools/tests/wizard/namedwizardtests/__init__.py
diff --git a/django/contrib/formtools/wizard/tests/namedwizardtests/forms.py b/django/contrib/formtools/tests/wizard/namedwizardtests/forms.py
index ae981269f8..ae981269f8 100644
--- a/django/contrib/formtools/wizard/tests/namedwizardtests/forms.py
+++ b/django/contrib/formtools/tests/wizard/namedwizardtests/forms.py
diff --git a/django/contrib/formtools/wizard/tests/namedwizardtests/tests.py b/django/contrib/formtools/tests/wizard/namedwizardtests/tests.py
index b3fb290698..0f63882b01 100644
--- a/django/contrib/formtools/wizard/tests/namedwizardtests/tests.py
+++ b/django/contrib/formtools/tests/wizard/namedwizardtests/tests.py
@@ -4,16 +4,12 @@ from django.test import TestCase
from django.contrib.auth.models import User
-from django.contrib.formtools import wizard
-
from django.contrib.formtools.wizard.views import (NamedUrlSessionWizardView,
NamedUrlCookieWizardView)
-from django.contrib.formtools.wizard.tests.formtests import (get_request,
- Step1,
- Step2)
+from django.contrib.formtools.tests.wizard.forms import get_request, Step1, Step2
class NamedWizardTests(object):
- urls = 'django.contrib.formtools.wizard.tests.namedwizardtests.urls'
+ urls = 'django.contrib.formtools.tests.wizard.namedwizardtests.urls'
def setUp(self):
self.testuser, created = User.objects.get_or_create(username='testuser1')
@@ -310,7 +306,7 @@ class NamedCookieWizardTests(NamedWizardTests, TestCase):
class NamedFormTests(object):
- urls = 'django.contrib.formtools.wizard.tests.namedwizardtests.urls'
+ urls = 'django.contrib.formtools.tests.wizard.namedwizardtests.urls'
def test_revalidation(self):
request = get_request()
diff --git a/django/contrib/formtools/wizard/tests/namedwizardtests/urls.py b/django/contrib/formtools/tests/wizard/namedwizardtests/urls.py
index a97ca98c1b..04019d127f 100644
--- a/django/contrib/formtools/wizard/tests/namedwizardtests/urls.py
+++ b/django/contrib/formtools/tests/wizard/namedwizardtests/urls.py
@@ -1,5 +1,5 @@
-from django.conf.urls.defaults import *
-from django.contrib.formtools.wizard.tests.namedwizardtests.forms import (
+from django.conf.urls.defaults import patterns, url
+from django.contrib.formtools.tests.wizard.namedwizardtests.forms import (
SessionContactWizard, CookieContactWizard, Page1, Page2, Page3, Page4)
def get_named_session_wizard():
diff --git a/django/contrib/formtools/wizard/tests/sessionstoragetests.py b/django/contrib/formtools/tests/wizard/sessionstorage.py
index c643921a40..85410725c9 100644
--- a/django/contrib/formtools/wizard/tests/sessionstoragetests.py
+++ b/django/contrib/formtools/tests/wizard/sessionstorage.py
@@ -1,8 +1,9 @@
from django.test import TestCase
-from django.contrib.formtools.wizard.tests.storagetests import TestStorage
+from django.contrib.formtools.tests.wizard.storage import TestStorage
from django.contrib.formtools.wizard.storage.session import SessionStorage
+
class TestSessionStorage(TestStorage, TestCase):
def get_storage(self):
return SessionStorage
diff --git a/django/contrib/formtools/wizard/tests/storagetests.py b/django/contrib/formtools/tests/wizard/storage.py
index fec4fae0ef..fe1d96381f 100644
--- a/django/contrib/formtools/wizard/tests/storagetests.py
+++ b/django/contrib/formtools/tests/wizard/storage.py
@@ -6,12 +6,14 @@ from django.utils.importlib import import_module
from django.contrib.auth.models import User
+
def get_request():
request = HttpRequest()
engine = import_module(settings.SESSION_ENGINE)
request.session = engine.SessionStore(None)
return request
+
class TestStorage(object):
def setUp(self):
self.testuser, created = User.objects.get_or_create(username='testuser1')
@@ -73,4 +75,3 @@ class TestStorage(object):
storage.extra_data = extra_context
storage2 = self.get_storage()('wizard2', request, None)
self.assertEqual(storage2.extra_data, {})
-
diff --git a/django/contrib/formtools/tests/wizard/wizardtests/__init__.py b/django/contrib/formtools/tests/wizard/wizardtests/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/django/contrib/formtools/tests/wizard/wizardtests/__init__.py
diff --git a/django/contrib/formtools/wizard/tests/wizardtests/forms.py b/django/contrib/formtools/tests/wizard/wizardtests/forms.py
index 726d74abee..bbc96c3453 100644
--- a/django/contrib/formtools/wizard/tests/wizardtests/forms.py
+++ b/django/contrib/formtools/tests/wizard/wizardtests/forms.py
@@ -34,7 +34,7 @@ class ContactWizard(WizardView):
def done(self, form_list, **kwargs):
c = Context({
'form_list': [x.cleaned_data for x in form_list],
- 'all_cleaned_data': self.get_all_cleaned_data()
+ 'all_cleaned_data': self.get_all_cleaned_data(),
})
for form in self.form_list.keys():
diff --git a/django/contrib/formtools/wizard/tests/wizardtests/templates/other_wizard_form.html b/django/contrib/formtools/tests/wizard/wizardtests/templates/other_wizard_form.html
index 45f812cbae..45f812cbae 100644
--- a/django/contrib/formtools/wizard/tests/wizardtests/templates/other_wizard_form.html
+++ b/django/contrib/formtools/tests/wizard/wizardtests/templates/other_wizard_form.html
diff --git a/django/contrib/formtools/wizard/tests/wizardtests/tests.py b/django/contrib/formtools/tests/wizard/wizardtests/tests.py
index 9366a6d403..9868721ca2 100644
--- a/django/contrib/formtools/wizard/tests/wizardtests/tests.py
+++ b/django/contrib/formtools/tests/wizard/wizardtests/tests.py
@@ -5,10 +5,9 @@ from django.test import TestCase
from django.conf import settings
from django.contrib.auth.models import User
-from django.contrib.formtools import wizard
class WizardTests(object):
- urls = 'django.contrib.formtools.wizard.tests.wizardtests.urls'
+ urls = 'django.contrib.formtools.tests.wizard.wizardtests.urls'
def setUp(self):
self.testuser, created = User.objects.get_or_create(username='testuser1')
@@ -269,7 +268,7 @@ class WizardTestKwargs(TestCase):
'cookie_contact_wizard-current_step': 'form4',
}
)
- urls = 'django.contrib.formtools.wizard.tests.wizardtests.urls'
+ urls = 'django.contrib.formtools.tests.wizard.wizardtests.urls'
def setUp(self):
self.testuser, created = User.objects.get_or_create(username='testuser1')
diff --git a/django/contrib/formtools/wizard/tests/wizardtests/urls.py b/django/contrib/formtools/tests/wizard/wizardtests/urls.py
index 7b5e84e234..e6d18ea5d1 100644
--- a/django/contrib/formtools/wizard/tests/wizardtests/urls.py
+++ b/django/contrib/formtools/tests/wizard/wizardtests/urls.py
@@ -1,5 +1,5 @@
from django.conf.urls.defaults import *
-from django.contrib.formtools.wizard.tests.wizardtests.forms import (
+from django.contrib.formtools.tests.wizard.wizardtests.forms import (
SessionContactWizard, CookieContactWizard, Page1, Page2, Page3, Page4)
urlpatterns = patterns('',
diff --git a/django/contrib/formtools/wizard/tests/__init__.py b/django/contrib/formtools/wizard/tests/__init__.py
deleted file mode 100644
index 7c66c82efc..0000000000
--- a/django/contrib/formtools/wizard/tests/__init__.py
+++ /dev/null
@@ -1,6 +0,0 @@
-from django.contrib.formtools.wizard.tests.formtests import *
-from django.contrib.formtools.wizard.tests.sessionstoragetests import *
-from django.contrib.formtools.wizard.tests.cookiestoragetests import *
-from django.contrib.formtools.wizard.tests.loadstoragetests import *
-from django.contrib.formtools.wizard.tests.wizardtests import *
-from django.contrib.formtools.wizard.tests.namedwizardtests import *
diff --git a/django/contrib/formtools/wizard/tests/namedwizardtests/__init__.py b/django/contrib/formtools/wizard/tests/namedwizardtests/__init__.py
deleted file mode 100644
index 4387356730..0000000000
--- a/django/contrib/formtools/wizard/tests/namedwizardtests/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from django.contrib.formtools.wizard.tests.namedwizardtests.tests import * \ No newline at end of file
diff --git a/django/contrib/formtools/wizard/tests/wizardtests/__init__.py b/django/contrib/formtools/wizard/tests/wizardtests/__init__.py
deleted file mode 100644
index 9173cd86d9..0000000000
--- a/django/contrib/formtools/wizard/tests/wizardtests/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from django.contrib.formtools.wizard.tests.wizardtests.tests import * \ No newline at end of file
diff --git a/docs/ref/contrib/formtools/form-wizard.txt b/docs/ref/contrib/formtools/form-wizard.txt
index 036c42cdd2..2645c28a32 100644
--- a/docs/ref/contrib/formtools/form-wizard.txt
+++ b/docs/ref/contrib/formtools/form-wizard.txt
@@ -51,7 +51,7 @@ you just have to do these things:
generic template to handle every one of the forms, or you can define a
specific template for each form.
- 4. Add ``django.contrib.formtools.wizard`` to your
+ 4. Add ``django.contrib.formtools`` to your
:setting:`INSTALLED_APPS` list in your settings file.
5. Point your URLconf at your :class:`WizardView` :meth:`~WizardView.as_view` method.
diff --git a/docs/ref/contrib/index.txt b/docs/ref/contrib/index.txt
index f62c8fc36e..37216468b9 100644
--- a/docs/ref/contrib/index.txt
+++ b/docs/ref/contrib/index.txt
@@ -102,7 +102,7 @@ An abstraction of the following workflow:
See the :doc:`form preview documentation </ref/contrib/formtools/form-preview>`.
django.contrib.formtools.wizard
---------------------------------
+-------------------------------
Splits forms across multiple Web pages.
diff --git a/tests/runtests.py b/tests/runtests.py
index 6d4f282a96..ba66d2aa11 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -35,7 +35,6 @@ ALWAYS_INSTALLED_APPS = [
'django.contrib.admindocs',
'django.contrib.staticfiles',
'django.contrib.humanize',
- 'django.contrib.formtools.wizard',
'regressiontests.staticfiles_tests',
'regressiontests.staticfiles_tests.apps.test',
'regressiontests.staticfiles_tests.apps.no_label',