Fixed some bugs with formtools tests.

Without these checks, it is possible for the tests to pass by virtue of
asserts never being reached for some reason (very possible in this case, due
to handling of security hashes).

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15198 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Luke Plant 2011-01-13 23:18:54 +00:00
parent a6b9dbc57c
commit cfcb591dd8
1 changed files with 6 additions and 0 deletions

View File

@ -356,11 +356,13 @@ class WizardTests(TestCase):
Regression test for ticket #14498. All previous steps' forms should be Regression test for ticket #14498. All previous steps' forms should be
validated. validated.
""" """
reached = [False]
that = self that = self
class WizardWithProcessStep(WizardClass): class WizardWithProcessStep(WizardClass):
def process_step(self, request, form, step): def process_step(self, request, form, step):
that.assertTrue(hasattr(form, 'cleaned_data')) that.assertTrue(hasattr(form, 'cleaned_data'))
reached[0] = True
wizard = WizardWithProcessStep([WizardPageOneForm, wizard = WizardWithProcessStep([WizardPageOneForm,
WizardPageTwoForm, WizardPageTwoForm,
@ -370,6 +372,7 @@ class WizardTests(TestCase):
"hash_0": "7e9cea465f6a10a6fb47fcea65cb9a76350c9a5c", "hash_0": "7e9cea465f6a10a6fb47fcea65cb9a76350c9a5c",
"wizard_step": "1"} "wizard_step": "1"}
wizard(DummyRequest(POST=data)) wizard(DummyRequest(POST=data))
self.assertTrue(reached[0])
def test_14576(self): def test_14576(self):
""" """
@ -400,6 +403,7 @@ class WizardTests(TestCase):
Regression test for ticket #15075. Allow modifying wizard's form_list Regression test for ticket #15075. Allow modifying wizard's form_list
in process_step. in process_step.
""" """
reached = [False]
that = self that = self
class WizardWithProcessStep(WizardClass): class WizardWithProcessStep(WizardClass):
@ -408,6 +412,7 @@ class WizardTests(TestCase):
self.form_list[1] = WizardPageTwoAlternativeForm self.form_list[1] = WizardPageTwoAlternativeForm
if step == 1: if step == 1:
that.assertTrue(isinstance(form, WizardPageTwoAlternativeForm)) that.assertTrue(isinstance(form, WizardPageTwoAlternativeForm))
reached[0] = True
wizard = WizardWithProcessStep([WizardPageOneForm, wizard = WizardWithProcessStep([WizardPageOneForm,
WizardPageTwoForm, WizardPageTwoForm,
@ -417,3 +422,4 @@ class WizardTests(TestCase):
"hash_0": "7e9cea465f6a10a6fb47fcea65cb9a76350c9a5c", "hash_0": "7e9cea465f6a10a6fb47fcea65cb9a76350c9a5c",
"wizard_step": "1"} "wizard_step": "1"}
wizard(DummyRequest(POST=data)) wizard(DummyRequest(POST=data))
self.assertTrue(reached[0])