Marked tests of BinaryFields as expected failures on MySQL and Python 3.

Current ports of MySQLdb are very buggy in this area.
This commit is contained in:
Aymeric Augustin 2013-05-08 15:33:02 +02:00
parent 86b4ac665a
commit 7476d96f83
3 changed files with 14 additions and 2 deletions

View File

@ -259,6 +259,9 @@ At the time of writing, the latest release of MySQLdb (1.2.4) doesn't support
Python 3. In order to use MySQL under Python 3, you'll have to install an Python 3. In order to use MySQL under Python 3, you'll have to install an
unofficial fork, such as `MySQL-for-Python-3`_. unofficial fork, such as `MySQL-for-Python-3`_.
This port is still in alpha. In particular, it doesn't support binary data,
making it impossible to use :class:`django.db.models.BinaryField`.
.. _MySQL-for-Python-3: https://github.com/clelland/MySQL-for-Python-3 .. _MySQL-for-Python-3: https://github.com/clelland/MySQL-for-Python-3
Creating your database Creating your database

View File

@ -6,7 +6,7 @@ from decimal import Decimal
from django import test from django import test
from django import forms from django import forms
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.db import models, IntegrityError from django.db import connection, models, IntegrityError
from django.db.models.fields.files import FieldFile from django.db.models.fields.files import FieldFile
from django.utils import six from django.utils import six
from django.utils import unittest from django.utils import unittest
@ -455,6 +455,10 @@ class BinaryFieldTests(test.TestCase):
# Test default value # Test default value
self.assertEqual(bytes(dm.short_data), b'\x08') self.assertEqual(bytes(dm.short_data), b'\x08')
if connection.vendor == 'mysql' and six.PY3:
# Existing MySQL DB-API drivers fail on binary data.
test_set_and_retrieve = unittest.expectedFailure(test_set_and_retrieve)
def test_max_length(self): def test_max_length(self):
dm = DataModel(short_data=self.binary_data*4) dm = DataModel(short_data=self.binary_data*4)
self.assertRaises(ValidationError, dm.full_clean) self.assertRaises(ValidationError, dm.full_clean)

View File

@ -26,7 +26,7 @@ from django.test import TestCase
from django.utils import six from django.utils import six
from django.utils.encoding import force_text from django.utils.encoding import force_text
from django.utils.functional import curry from django.utils.functional import curry
from django.utils.unittest import skipUnless from django.utils.unittest import expectedFailure, skipUnless
from .models import (BinaryData, BooleanData, CharData, DateData, DateTimeData, EmailData, from .models import (BinaryData, BooleanData, CharData, DateData, DateTimeData, EmailData,
FileData, FilePathData, DecimalData, FloatData, IntegerData, IPAddressData, FileData, FilePathData, DecimalData, FloatData, IntegerData, IPAddressData,
@ -459,6 +459,11 @@ def serializerTest(format, self):
for klass, count in instance_count.items(): for klass, count in instance_count.items():
self.assertEqual(count, klass.objects.count()) self.assertEqual(count, klass.objects.count())
if connection.vendor == 'mysql' and six.PY3:
# Existing MySQL DB-API drivers fail on binary data.
serializerTest = expectedFailure(serializerTest)
def naturalKeySerializerTest(format, self): def naturalKeySerializerTest(format, self):
# Create all the objects defined in the test data # Create all the objects defined in the test data
objects = [] objects = []