Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #6644 -- Fixed django.contrib.formtools tests to be better isol…

…ated 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
  • Loading branch information...
commit a13de6cd76b12da0520ddccb2d746dd73eb70d28 1 parent 566b329
@jezdez jezdez authored
Showing with 60 additions and 44 deletions.
  1. 0  django/contrib/formtools/{wizard → }/templates/formtools/wizard/wizard_form.html
  2. +21 −13 django/contrib/formtools/tests/__init__.py
  3. +2 −2 django/contrib/formtools/tests/forms.py
  4. +2 −0  django/contrib/formtools/tests/templates/base.html
  5. +17 −0 django/contrib/formtools/tests/wizard/__init__.py
  6. +2 −1  django/contrib/formtools/{wizard/tests/cookiestoragetests.py → tests/wizard/cookiestorage.py}
  7. +1 −1  django/contrib/formtools/{wizard/tests/formtests.py → tests/wizard/forms.py}
  8. 0  django/contrib/formtools/{wizard/tests/loadstoragetests.py → tests/wizard/loadstorage.py}
  9. 0  django/contrib/formtools/tests/wizard/namedwizardtests/__init__.py
  10. 0  django/contrib/formtools/{wizard/tests → tests/wizard}/namedwizardtests/forms.py
  11. +3 −7 django/contrib/formtools/{wizard/tests → tests/wizard}/namedwizardtests/tests.py
  12. +2 −2 django/contrib/formtools/{wizard/tests → tests/wizard}/namedwizardtests/urls.py
  13. +2 −1  django/contrib/formtools/{wizard/tests/sessionstoragetests.py → tests/wizard/sessionstorage.py}
  14. +2 −1  django/contrib/formtools/{wizard/tests/storagetests.py → tests/wizard/storage.py}
  15. 0  django/contrib/formtools/tests/wizard/wizardtests/__init__.py
  16. +1 −1  django/contrib/formtools/{wizard/tests → tests/wizard}/wizardtests/forms.py
  17. 0  django/contrib/formtools/{wizard/tests → tests/wizard}/wizardtests/templates/other_wizard_form.html
  18. +2 −3 django/contrib/formtools/{wizard/tests → tests/wizard}/wizardtests/tests.py
  19. +1 −1  django/contrib/formtools/{wizard/tests → tests/wizard}/wizardtests/urls.py
  20. +0 −6 django/contrib/formtools/wizard/tests/__init__.py
  21. +0 −1  django/contrib/formtools/wizard/tests/namedwizardtests/__init__.py
  22. +0 −1  django/contrib/formtools/wizard/tests/wizardtests/__init__.py
  23. +1 −1  docs/ref/contrib/formtools/form-wizard.txt
  24. +1 −1  docs/ref/contrib/index.txt
  25. +0 −1  tests/runtests.py
View
0  ...izard/templates/formtools/wizard/wizard_form.html → ...tools/templates/formtools/wizard/wizard_form.html
File renamed without changes
View
34 django/contrib/formtools/tests/__init__.py
@@ -4,12 +4,13 @@
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 @@ def done(self, request, cleaned_data):
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 @@ def setUp(self):
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 @@ def test_empty_permitted(self):
# FormWizard tests
#
-class TestWizardClass(wizard.FormWizard):
+class TestWizardClass(FormWizard):
def get_template(self, step):
return 'forms/wizard.html'
@@ -243,7 +257,7 @@ def __init__(self, POST=None):
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):
View
4 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("")
View
2  django/contrib/formtools/tests/templates/base.html
@@ -0,0 +1,2 @@
+{% block content %}
+{% endblock %}
View
17 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,
+)
View
3  ...trib/formtools/wizard/tests/cookiestoragetests.py → ...o/contrib/formtools/tests/wizard/cookiestorage.py
@@ -4,7 +4,8 @@
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):
View
2  django/contrib/formtools/wizard/tests/formtests.py → django/contrib/formtools/tests/wizard/forms.py
@@ -20,6 +20,7 @@ def __init__(self, POST=None):
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 @@ def test_init(self):
request = get_request()
testform = CookieWizardView.as_view([('start', Step1)])
self.assertTrue(isinstance(testform(request), TemplateResponse))
-
View
0  ...ontrib/formtools/wizard/tests/loadstoragetests.py → django/contrib/formtools/tests/wizard/loadstorage.py
File renamed without changes
View
0  django/contrib/formtools/tests/wizard/namedwizardtests/__init__.py
No changes.
View
0  .../formtools/wizard/tests/namedwizardtests/forms.py → .../formtools/tests/wizard/namedwizardtests/forms.py
File renamed without changes
View
10 .../formtools/wizard/tests/namedwizardtests/tests.py → .../formtools/tests/wizard/namedwizardtests/tests.py
@@ -4,16 +4,12 @@
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()
View
4 ...b/formtools/wizard/tests/namedwizardtests/urls.py → ...b/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():
View
3  ...rib/formtools/wizard/tests/sessionstoragetests.py → .../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
View
3  ...go/contrib/formtools/wizard/tests/storagetests.py → django/contrib/formtools/tests/wizard/storage.py
@@ -6,12 +6,14 @@
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 @@ def test_extra_context(self):
storage.extra_data = extra_context
storage2 = self.get_storage()('wizard2', request, None)
self.assertEqual(storage2.extra_data, {})
-
View
0  django/contrib/formtools/tests/wizard/wizardtests/__init__.py
No changes.
View
2  ...ntrib/formtools/wizard/tests/wizardtests/forms.py → ...ntrib/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():
View
0  ...ests/wizardtests/templates/other_wizard_form.html → ...zard/wizardtests/templates/other_wizard_form.html
File renamed without changes
View
5 ...ntrib/formtools/wizard/tests/wizardtests/tests.py → ...ntrib/formtools/tests/wizard/wizardtests/tests.py
@@ -5,10 +5,9 @@
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')
View
2  ...ontrib/formtools/wizard/tests/wizardtests/urls.py → ...ontrib/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('',
View
6 django/contrib/formtools/wizard/tests/__init__.py
@@ -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 *
View
1  django/contrib/formtools/wizard/tests/namedwizardtests/__init__.py
@@ -1 +0,0 @@
-from django.contrib.formtools.wizard.tests.namedwizardtests.tests import *
View
1  django/contrib/formtools/wizard/tests/wizardtests/__init__.py
@@ -1 +0,0 @@
-from django.contrib.formtools.wizard.tests.wizardtests.tests import *
View
2  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.
View
2  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.
View
1  tests/runtests.py
@@ -35,7 +35,6 @@
'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',
Please sign in to comment.
Something went wrong with that request. Please try again.