From 2a05a82311f631f314e2918fdb7de983b4c5682a Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Sun, 3 May 2015 09:06:06 +0200 Subject: [PATCH] Worked around a bug when chaining skipIf/UnlessDBFeature. --- tests/timezones/tests.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/timezones/tests.py b/tests/timezones/tests.py index 1fd12c5f3a..825663436c 100644 --- a/tests/timezones/tests.py +++ b/tests/timezones/tests.py @@ -4,7 +4,7 @@ import datetime import re import sys import warnings -from unittest import skipIf +from unittest import SkipTest, skipIf from xml.dom.minidom import parseString from django.contrib.auth.models import User @@ -622,9 +622,6 @@ class NewDatabaseTests(TestCase): self.assertEqual(e.dt, None) -# TODO: chaining @skipIfDBFeature and @skipUnlessDBFeature doesn't work! -@skipIfDBFeature('supports_timezones') -@skipUnlessDBFeature('test_db_allows_multiple_connections') @override_settings(TIME_ZONE='Africa/Nairobi', USE_TZ=True) class ForcedTimeZoneDatabaseTests(TransactionTestCase): """ @@ -638,6 +635,13 @@ class ForcedTimeZoneDatabaseTests(TransactionTestCase): @classmethod def setUpClass(cls): + # @skipIfDBFeature and @skipUnlessDBFeature cannot be chained. The + # outermost takes precedence. Handle skipping manually instead. + if connection.features.supports_timezones: + raise SkipTest("Database has feature(s) supports_timezones") + if not connection.features.test_db_allows_multiple_connections: + raise SkipTest("Database doesn't support feature(s): test_db_allows_multiple_connections") + super(ForcedTimeZoneDatabaseTests, cls).setUpClass() connections.databases['tz'] = connections.databases['default'].copy() connections.databases['tz']['TIME_ZONE'] = 'Asia/Bangkok'