diff options
author | Aurélien Bompard <aurelien@bompard.org> | 2013-07-23 11:45:40 +0200 |
---|---|---|
committer | Aurélien Bompard <aurelien@bompard.org> | 2013-07-23 11:45:40 +0200 |
commit | 8333abc9062ff0e7345dec41db972c0992c534e0 (patch) | |
tree | e47334f27f56e86eca6e01812a21cfee9292959f /hyperkitty/tests | |
parent | bf2de4165365d96dcafdfc769ac6020348a45c6e (diff) | |
download | hyperkitty-8333abc9062ff0e7345dec41db972c0992c534e0.tar.gz hyperkitty-8333abc9062ff0e7345dec41db972c0992c534e0.tar.xz hyperkitty-8333abc9062ff0e7345dec41db972c0992c534e0.zip |
Centralize settings modifications for unittests in a single class
Diffstat (limited to 'hyperkitty/tests')
-rw-r--r-- | hyperkitty/tests/test_lib.py | 2 | ||||
-rw-r--r-- | hyperkitty/tests/test_models.py | 2 | ||||
-rw-r--r-- | hyperkitty/tests/test_templatetags.py | 2 | ||||
-rw-r--r-- | hyperkitty/tests/test_views.py | 2 | ||||
-rw-r--r-- | hyperkitty/tests/utils.py | 50 |
5 files changed, 54 insertions, 4 deletions
diff --git a/hyperkitty/tests/test_lib.py b/hyperkitty/tests/test_lib.py index 4b9b778..19f31d1 100644 --- a/hyperkitty/tests/test_lib.py +++ b/hyperkitty/tests/test_lib.py @@ -21,7 +21,7 @@ import datetime -from django.test import TestCase +from hyperkitty.tests.utils import TestCase from hyperkitty.lib.view_helpers import get_display_dates, paginate diff --git a/hyperkitty/tests/test_models.py b/hyperkitty/tests/test_models.py index 120e571..bcbcf58 100644 --- a/hyperkitty/tests/test_models.py +++ b/hyperkitty/tests/test_models.py @@ -19,7 +19,7 @@ # Author: Aamir Khan <syst3m.w0rm@gmail.com> # -from django.test import TestCase +from hyperkitty.tests.utils import TestCase from hyperkitty.models import Rating, Tag class RatingTestCase(TestCase): diff --git a/hyperkitty/tests/test_templatetags.py b/hyperkitty/tests/test_templatetags.py index f4d9d4d..6763992 100644 --- a/hyperkitty/tests/test_templatetags.py +++ b/hyperkitty/tests/test_templatetags.py @@ -19,7 +19,7 @@ # Author: Aurelien Bompard <abompard@fedoraproject.org> # -from django.test import TestCase +from hyperkitty.tests.utils import TestCase from hyperkitty.templatetags.hk_generic import snip_quoted diff --git a/hyperkitty/tests/test_views.py b/hyperkitty/tests/test_views.py index b39544c..bd672b2 100644 --- a/hyperkitty/tests/test_views.py +++ b/hyperkitty/tests/test_views.py @@ -25,7 +25,7 @@ import datetime from mock import Mock import django.utils.simplejson as json -from django.test import TestCase +from hyperkitty.tests.utils import TestCase from django.test.client import Client, RequestFactory from django.contrib.auth.models import User, AnonymousUser from django.core.urlresolvers import reverse diff --git a/hyperkitty/tests/utils.py b/hyperkitty/tests/utils.py new file mode 100644 index 0000000..5124f39 --- /dev/null +++ b/hyperkitty/tests/utils.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 1998-2012 by the Free Software Foundation, Inc. +# +# This file is part of HyperKitty. +# +# HyperKitty is free software: you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) +# any later version. +# +# HyperKitty is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# HyperKitty. If not, see <http://www.gnu.org/licenses/>. +# +# Author: Aurelien Bompard <abompard@fedoraproject.org> +# + + +from django.test import TestCase as DjangoTestCase +from django.conf import settings + + +OVERRIDE_SETTINGS = { + "TEMPLATE_DEBUG": True, + "ASSETS_DEBUG": True, + "USE_SSL": False, + "KITTYSTORE_URL": 'sqlite:', + "KITTYSTORE_SEARCH_INDEX": None, + "KITTYSTORE_DEBUG": False, + "USE_MOCKUPS": False, +} + + +class TestCase(DjangoTestCase): + + def _pre_setup(self): + super(TestCase, self)._pre_setup() + self._old_settings = {} + for key, value in OVERRIDE_SETTINGS.iteritems(): + self._old_settings[key] = getattr(settings, key) + setattr(settings, key, value) + + def _post_teardown(self): + super(TestCase, self)._post_teardown() + for key, value in self._old_settings.iteritems(): + setattr(settings, key, value) |