mirror of https://github.com/django/django.git
Avoided using BinaryField unecessarily in tests.
Several database backends struggle with binary data. This change minimizes the risk of unrelated tests failures when binary fields trigger errors.
This commit is contained in:
parent
4fb50a9a82
commit
2e4bcb9b02
|
@ -64,7 +64,6 @@ class Post(models.Model):
|
||||||
class Reporter(models.Model):
|
class Reporter(models.Model):
|
||||||
first_name = models.CharField(max_length=30)
|
first_name = models.CharField(max_length=30)
|
||||||
last_name = models.CharField(max_length=30)
|
last_name = models.CharField(max_length=30)
|
||||||
raw_data = models.BinaryField()
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%s %s" % (self.first_name, self.last_name)
|
return "%s %s" % (self.first_name, self.last_name)
|
||||||
|
@ -112,3 +111,7 @@ class ObjectReference(models.Model):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.obj_id)
|
return str(self.obj_id)
|
||||||
|
|
||||||
|
|
||||||
|
class RawData(models.Model):
|
||||||
|
raw_data = models.BinaryField()
|
||||||
|
|
|
@ -334,9 +334,9 @@ class LastExecutedQueryTest(TestCase):
|
||||||
"""
|
"""
|
||||||
Test that last_executed_query() returns an Unicode string
|
Test that last_executed_query() returns an Unicode string
|
||||||
"""
|
"""
|
||||||
persons = models.Reporter.objects.filter(raw_data=b'\x00\x46 \xFE').extra(select={'föö': 1})
|
data = models.RawData.objects.filter(raw_data=b'\x00\x46 \xFE').extra(select={'föö': 1})
|
||||||
sql, params = persons.query.sql_with_params()
|
sql, params = data.query.sql_with_params()
|
||||||
cursor = persons.query.get_compiler('default').execute_sql(CURSOR)
|
cursor = data.query.get_compiler('default').execute_sql(CURSOR)
|
||||||
last_sql = cursor.db.ops.last_executed_query(cursor, sql, params)
|
last_sql = cursor.db.ops.last_executed_query(cursor, sql, params)
|
||||||
self.assertIsInstance(last_sql, six.text_type)
|
self.assertIsInstance(last_sql, six.text_type)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue