From cf040e4896e8a989b51c015d4ffbbaf3f439268a Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sat, 2 Nov 2013 10:18:46 -0700 Subject: [PATCH] Continue to attack E302 violations --- formtools/tests/wizard/namedwizardtests/forms.py | 6 ++++++ formtools/tests/wizard/namedwizardtests/urls.py | 2 ++ formtools/tests/wizard/test_forms.py | 2 ++ formtools/tests/wizard/wizardtests/forms.py | 7 +++++++ formtools/wizard/forms.py | 1 + formtools/wizard/storage/exceptions.py | 2 ++ formtools/wizard/views.py | 1 + 7 files changed, 21 insertions(+) diff --git a/formtools/tests/wizard/namedwizardtests/forms.py b/formtools/tests/wizard/namedwizardtests/forms.py index c89f51e..fa9071d 100644 --- a/formtools/tests/wizard/namedwizardtests/forms.py +++ b/formtools/tests/wizard/namedwizardtests/forms.py @@ -14,21 +14,25 @@ from django.contrib.formtools.wizard.views import NamedUrlWizardView temp_storage_location = tempfile.mkdtemp(dir=os.environ.get('DJANGO_TEST_TEMP_DIR')) temp_storage = FileSystemStorage(location=temp_storage_location) + class Page1(forms.Form): name = forms.CharField(max_length=100) user = forms.ModelChoiceField(queryset=User.objects.all()) thirsty = forms.NullBooleanField() + class Page2(forms.Form): address1 = forms.CharField(max_length=100) address2 = forms.CharField(max_length=100) file1 = forms.FileField() + class Page3(forms.Form): random_crap = forms.CharField(max_length=100) Page4 = formset_factory(Page3, extra=2) + class ContactWizard(NamedUrlWizardView): file_storage = temp_storage @@ -44,8 +48,10 @@ class ContactWizard(NamedUrlWizardView): c['this_will_fail'] = self.get_cleaned_data_for_step('this_will_fail') return HttpResponse(Template('').render(c)) + class SessionContactWizard(ContactWizard): storage_name = 'django.contrib.formtools.wizard.storage.session.SessionStorage' + class CookieContactWizard(ContactWizard): storage_name = 'django.contrib.formtools.wizard.storage.cookie.CookieStorage' diff --git a/formtools/tests/wizard/namedwizardtests/urls.py b/formtools/tests/wizard/namedwizardtests/urls.py index ac2cadc..a88e711 100644 --- a/formtools/tests/wizard/namedwizardtests/urls.py +++ b/formtools/tests/wizard/namedwizardtests/urls.py @@ -2,6 +2,7 @@ from django.conf.urls import patterns, url from django.contrib.formtools.tests.wizard.namedwizardtests.forms import ( SessionContactWizard, CookieContactWizard, Page1, Page2, Page3, Page4) + def get_named_session_wizard(): return SessionContactWizard.as_view( [('form1', Page1), ('form2', Page2), ('form3', Page3), ('form4', Page4)], @@ -9,6 +10,7 @@ def get_named_session_wizard(): done_step_name='nwiz_session_done' ) + def get_named_cookie_wizard(): return CookieContactWizard.as_view( [('form1', Page1), ('form2', Page2), ('form3', Page3), ('form4', Page4)], diff --git a/formtools/tests/wizard/test_forms.py b/formtools/tests/wizard/test_forms.py index ba3fbfd..386e448 100644 --- a/formtools/tests/wizard/test_forms.py +++ b/formtools/tests/wizard/test_forms.py @@ -81,12 +81,14 @@ class TestWizard(WizardView): kwargs['test'] = True return kwargs + class TestWizardWithInitAttrs(TestWizard): form_list = [Step1, Step2] condition_dict = {'step2': True} initial_dict = {'start': {'name': 'value1'}} instance_dict = {'start': User()} + class FormTests(TestCase): def test_form_init(self): testform = TestWizard.get_initkwargs([Step1, Step2]) diff --git a/formtools/tests/wizard/wizardtests/forms.py b/formtools/tests/wizard/wizardtests/forms.py index ad56547..5e4617c 100644 --- a/formtools/tests/wizard/wizardtests/forms.py +++ b/formtools/tests/wizard/wizardtests/forms.py @@ -15,21 +15,25 @@ from django.contrib.formtools.wizard.views import WizardView temp_storage_location = tempfile.mkdtemp(dir=os.environ.get('DJANGO_TEST_TEMP_DIR')) temp_storage = FileSystemStorage(location=temp_storage_location) + class Page1(forms.Form): name = forms.CharField(max_length=100) user = forms.ModelChoiceField(queryset=User.objects.all()) thirsty = forms.NullBooleanField() + class Page2(forms.Form): address1 = forms.CharField(max_length=100) address2 = forms.CharField(max_length=100) file1 = forms.FileField() + class Page3(forms.Form): random_crap = forms.CharField(max_length=100) Page4 = formset_factory(Page3, extra=2) + class ContactWizard(WizardView): file_storage = temp_storage @@ -51,6 +55,7 @@ class ContactWizard(WizardView): context.update({'another_var': True}) return context + class UserForm(forms.ModelForm): class Meta: model = User @@ -58,8 +63,10 @@ class UserForm(forms.ModelForm): UserFormSet = modelformset_factory(User, form=UserForm) + class SessionContactWizard(ContactWizard): storage_name = 'django.contrib.formtools.wizard.storage.session.SessionStorage' + class CookieContactWizard(ContactWizard): storage_name = 'django.contrib.formtools.wizard.storage.cookie.CookieStorage' diff --git a/formtools/wizard/forms.py b/formtools/wizard/forms.py index bf46c5c..cd00517 100644 --- a/formtools/wizard/forms.py +++ b/formtools/wizard/forms.py @@ -1,5 +1,6 @@ from django import forms + class ManagementForm(forms.Form): """ ``ManagementForm`` is used to keep track of the current wizard step. diff --git a/formtools/wizard/storage/exceptions.py b/formtools/wizard/storage/exceptions.py index e273a86..31cea93 100644 --- a/formtools/wizard/storage/exceptions.py +++ b/formtools/wizard/storage/exceptions.py @@ -1,7 +1,9 @@ from django.core.exceptions import ImproperlyConfigured + class MissingStorage(ImproperlyConfigured): pass + class NoFileStorageConfigured(ImproperlyConfigured): pass diff --git a/formtools/wizard/views.py b/formtools/wizard/views.py index f1c54f5..f19cfc7 100644 --- a/formtools/wizard/views.py +++ b/formtools/wizard/views.py @@ -28,6 +28,7 @@ def normalize_name(name): new = re.sub('(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))', '_\\1', name) return new.lower().strip('_') + class StepsHelper(object): def __init__(self, wizard):