From 43f6f45c3671a224c64e46d724f2176d57eef1fa Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Sat, 31 Mar 2012 16:03:09 +0000 Subject: [PATCH] Used the override_settings decorator in the tests of auth, flatpages, and formtools. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17851 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- formtools/templates/404.html | 1 + formtools/tests/__init__.py | 38 +++++++++++++----------------------- 2 files changed, 15 insertions(+), 24 deletions(-) create mode 100644 formtools/templates/404.html diff --git a/formtools/templates/404.html b/formtools/templates/404.html new file mode 100644 index 0000000..4aa1203 --- /dev/null +++ b/formtools/templates/404.html @@ -0,0 +1 @@ +Not found. diff --git a/formtools/tests/__init__.py b/formtools/tests/__init__.py index d659403..e628690 100644 --- a/formtools/tests/__init__.py +++ b/formtools/tests/__init__.py @@ -7,6 +7,7 @@ from django.conf import settings from django.contrib.formtools import preview, utils from django.contrib.formtools.wizard import FormWizard from django.test import TestCase +from django.test.utils import override_settings from django.utils import unittest from django.contrib.formtools.tests.wizard import * @@ -29,19 +30,12 @@ class TestFormPreview(preview.FormPreview): def done(self, request, cleaned_data): return http.HttpResponse(success_string) - -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): +@override_settings( + TEMPLATE_DIRS=( + os.path.join(os.path.dirname(__file__), 'templates'), + ), +) +class PreviewTests(TestCase): urls = 'django.contrib.formtools.tests.urls' def setUp(self): @@ -215,7 +209,13 @@ class DummyRequest(http.HttpRequest): self._dont_enforce_csrf_checks = True -class WizardTests(FormToolsTestCase): +@override_settings( + SECRET_KEY="123", + TEMPLATE_DIRS=( + os.path.join(os.path.dirname(__file__), 'templates'), + ), +) +class WizardTests(TestCase): urls = 'django.contrib.formtools.tests.urls' input_re = re.compile('name="([^"]+)" value="([^"]+)"') wizard_step_data = ( @@ -232,16 +232,6 @@ class WizardTests(FormToolsTestCase): } ) - def setUp(self): - 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): - super(WizardTests, self).tearDown() - settings.SECRET_KEY = self.old_SECRET_KEY - def test_step_starts_at_zero(self): """ step should be zero for the first form