Worked around a bug when chaining skipIf/UnlessDBFeature.
This commit is contained in:
parent
ed83881e64
commit
2a05a82311
|
@ -4,7 +4,7 @@ import datetime
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
from unittest import skipIf
|
from unittest import SkipTest, skipIf
|
||||||
from xml.dom.minidom import parseString
|
from xml.dom.minidom import parseString
|
||||||
|
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
@ -622,9 +622,6 @@ class NewDatabaseTests(TestCase):
|
||||||
self.assertEqual(e.dt, None)
|
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)
|
@override_settings(TIME_ZONE='Africa/Nairobi', USE_TZ=True)
|
||||||
class ForcedTimeZoneDatabaseTests(TransactionTestCase):
|
class ForcedTimeZoneDatabaseTests(TransactionTestCase):
|
||||||
"""
|
"""
|
||||||
|
@ -638,6 +635,13 @@ class ForcedTimeZoneDatabaseTests(TransactionTestCase):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
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()
|
super(ForcedTimeZoneDatabaseTests, cls).setUpClass()
|
||||||
connections.databases['tz'] = connections.databases['default'].copy()
|
connections.databases['tz'] = connections.databases['default'].copy()
|
||||||
connections.databases['tz']['TIME_ZONE'] = 'Asia/Bangkok'
|
connections.databases['tz']['TIME_ZONE'] = 'Asia/Bangkok'
|
||||||
|
|
Loading…
Reference in New Issue