mirror of
https://github.com/django/django.git
synced 2025-09-06 10:40:49 +00:00
Fixed test failures on MySQL.
Some tests failed when the time zone definitions were loaded in MySQL and pytz wasn't installed. This setup isn't supported.
This commit is contained in:
parent
de8aa3a9a9
commit
1fff8daf88
3 changed files with 17 additions and 2 deletions
|
@ -30,6 +30,11 @@ if (version < (1, 2, 1) or (version[:3] == (1, 2, 1) and
|
|||
from MySQLdb.converters import conversions, Thing2Literal
|
||||
from MySQLdb.constants import FIELD_TYPE, CLIENT
|
||||
|
||||
try:
|
||||
import pytz
|
||||
except ImportError:
|
||||
pytz = None
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import utils
|
||||
from django.db.backends import *
|
||||
|
@ -186,6 +191,15 @@ class DatabaseFeatures(BaseDatabaseFeatures):
|
|||
|
||||
@cached_property
|
||||
def has_zoneinfo_database(self):
|
||||
# MySQL accepts full time zones names (eg. Africa/Nairobi) but rejects
|
||||
# abbreviations (eg. EAT). When pytz isn't installed and the current
|
||||
# time zone is LocalTimezone (the only sensible value in this
|
||||
# context), the current time zone name will be an abbreviation. As a
|
||||
# consequence, MySQL cannot perform time zone conversions reliably.
|
||||
if pytz is None:
|
||||
return False
|
||||
|
||||
# Test if the time zone definitions are installed.
|
||||
cursor = self.connection.cursor()
|
||||
cursor.execute("SELECT 1 FROM mysql.time_zone LIMIT 1")
|
||||
return cursor.fetchone() is not None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue