summaryrefslogtreecommitdiff
path: root/tests/or_lookups
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2015-12-12 23:09:13 +0100
committerClaude Paroz <claude@2xlibre.net>2015-12-13 15:07:17 +0100
commited20dd2e85a0bbd45085809417c29e92ced5e618 (patch)
tree370cfa35c35ccc1be5be57ab2d657915853403a0 /tests/or_lookups
parentd693074d431c50e4801dd6bf52525ce1436358f0 (diff)
downloaddjango-ed20dd2e85a0bbd45085809417c29e92ced5e618.tar.gz
Fixed #25875 -- Prevented UnicodeDecodeError for Q object repr
Thanks Ben Kraft for the report, and Simon Charette for the review.
Diffstat (limited to 'tests/or_lookups')
-rw-r--r--tests/or_lookups/tests.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/or_lookups/tests.py b/tests/or_lookups/tests.py
index 55afed3fc4..35c7f34d61 100644
--- a/tests/or_lookups/tests.py
+++ b/tests/or_lookups/tests.py
@@ -1,3 +1,4 @@
+# -*- encoding: utf-8 -*-
from __future__ import unicode_literals
from datetime import datetime
@@ -5,6 +6,7 @@ from operator import attrgetter
from django.db.models import Q
from django.test import TestCase
+from django.utils.encoding import force_str
from .models import Article
@@ -123,6 +125,12 @@ class OrLookupsTests(TestCase):
attrgetter("headline"),
)
+ def test_q_repr(self):
+ or_expr = Q(baz=Article(headline="Foö"))
+ self.assertEqual(repr(or_expr), force_str("<Q: (AND: ('baz', <Article: Foö>))>"))
+ negated_or = ~Q(baz=Article(headline="Foö"))
+ self.assertEqual(repr(negated_or), force_str("<Q: (NOT (AND: ('baz', <Article: Foö>)))>"))
+
def test_q_negated(self):
# Q objects can be negated
self.assertQuerysetEqual(