Changed assertQuerysetEqual()s that use default Model.__str__() to assertSequenceEqual().
This commit is contained in:
parent
eb9a3bd63a
commit
a19b373d89
|
@ -581,7 +581,7 @@ class ManyToOneTests(TestCase):
|
||||||
private_student = Student.objects.create(school=private_school)
|
private_student = Student.objects.create(school=private_school)
|
||||||
|
|
||||||
# Only one school is available via all() due to the custom default manager.
|
# Only one school is available via all() due to the custom default manager.
|
||||||
self.assertQuerysetEqual(School.objects.all(), ["<School: School object>"])
|
self.assertSequenceEqual(School.objects.all(), [public_school])
|
||||||
|
|
||||||
self.assertEqual(public_student.school, public_school)
|
self.assertEqual(public_student.school, public_school)
|
||||||
|
|
||||||
|
|
|
@ -23,19 +23,13 @@ class NullQueriesTests(TestCase):
|
||||||
|
|
||||||
# Exact query with value None returns nothing ("is NULL" in sql,
|
# Exact query with value None returns nothing ("is NULL" in sql,
|
||||||
# but every 'id' field has a value).
|
# but every 'id' field has a value).
|
||||||
self.assertQuerysetEqual(Choice.objects.filter(choice__exact=None), [])
|
self.assertSequenceEqual(Choice.objects.filter(choice__exact=None), [])
|
||||||
|
|
||||||
# The same behavior for iexact query.
|
# The same behavior for iexact query.
|
||||||
self.assertQuerysetEqual(Choice.objects.filter(choice__iexact=None), [])
|
self.assertSequenceEqual(Choice.objects.filter(choice__iexact=None), [])
|
||||||
|
|
||||||
# Excluding the previous result returns everything.
|
# Excluding the previous result returns everything.
|
||||||
self.assertQuerysetEqual(
|
self.assertSequenceEqual(Choice.objects.exclude(choice=None).order_by('id'), [c1, c2])
|
||||||
Choice.objects.exclude(choice=None).order_by('id'),
|
|
||||||
[
|
|
||||||
'<Choice: Choice: Because. in poll Q: Why? >',
|
|
||||||
'<Choice: Choice: Why Not? in poll Q: Why? >'
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
# Valid query, but fails because foo isn't a keyword
|
# Valid query, but fails because foo isn't a keyword
|
||||||
with self.assertRaises(FieldError):
|
with self.assertRaises(FieldError):
|
||||||
|
@ -55,30 +49,15 @@ class NullQueriesTests(TestCase):
|
||||||
insert outer joins correctly so as not to exclude results.
|
insert outer joins correctly so as not to exclude results.
|
||||||
"""
|
"""
|
||||||
obj = OuterA.objects.create()
|
obj = OuterA.objects.create()
|
||||||
self.assertQuerysetEqual(
|
self.assertSequenceEqual(OuterA.objects.filter(inner__third=None), [obj])
|
||||||
OuterA.objects.filter(inner__third=None),
|
self.assertSequenceEqual(OuterA.objects.filter(inner__third__data=None), [obj])
|
||||||
['<OuterA: OuterA object>']
|
|
||||||
)
|
|
||||||
self.assertQuerysetEqual(
|
|
||||||
OuterA.objects.filter(inner__third__data=None),
|
|
||||||
['<OuterA: OuterA object>']
|
|
||||||
)
|
|
||||||
|
|
||||||
Inner.objects.create(first=obj)
|
inner = Inner.objects.create(first=obj)
|
||||||
self.assertQuerysetEqual(
|
self.assertSequenceEqual(Inner.objects.filter(first__inner__third=None), [inner])
|
||||||
Inner.objects.filter(first__inner__third=None),
|
|
||||||
['<Inner: Inner object>']
|
|
||||||
)
|
|
||||||
|
|
||||||
# Ticket #13815: check if <reverse>_isnull=False does not produce
|
# Ticket #13815: check if <reverse>_isnull=False does not produce
|
||||||
# faulty empty lists
|
# faulty empty lists
|
||||||
OuterB.objects.create(data="reverse")
|
outerb = OuterB.objects.create(data='reverse')
|
||||||
self.assertQuerysetEqual(
|
self.assertSequenceEqual(OuterB.objects.filter(inner__isnull=False), [])
|
||||||
OuterB.objects.filter(inner__isnull=False),
|
|
||||||
[]
|
|
||||||
)
|
|
||||||
Inner.objects.create(first=obj)
|
Inner.objects.create(first=obj)
|
||||||
self.assertQuerysetEqual(
|
self.assertSequenceEqual(OuterB.objects.exclude(inner__isnull=False), [outerb])
|
||||||
OuterB.objects.exclude(inner__isnull=False),
|
|
||||||
['<OuterB: OuterB object>']
|
|
||||||
)
|
|
||||||
|
|
|
@ -254,24 +254,11 @@ class OneToOneTests(TestCase):
|
||||||
misbehaving. We test both (primary_key=True & False) cases here to
|
misbehaving. We test both (primary_key=True & False) cases here to
|
||||||
prevent any reappearance of the problem.
|
prevent any reappearance of the problem.
|
||||||
"""
|
"""
|
||||||
Target.objects.create()
|
target = Target.objects.create()
|
||||||
|
self.assertSequenceEqual(Target.objects.filter(pointer=None), [target])
|
||||||
self.assertQuerysetEqual(
|
self.assertSequenceEqual(Target.objects.exclude(pointer=None), [])
|
||||||
Target.objects.filter(pointer=None),
|
self.assertSequenceEqual(Target.objects.filter(second_pointer=None), [target])
|
||||||
['<Target: Target object>']
|
self.assertSequenceEqual(Target.objects.exclude(second_pointer=None), [])
|
||||||
)
|
|
||||||
self.assertQuerysetEqual(
|
|
||||||
Target.objects.exclude(pointer=None),
|
|
||||||
[]
|
|
||||||
)
|
|
||||||
self.assertQuerysetEqual(
|
|
||||||
Target.objects.filter(second_pointer=None),
|
|
||||||
['<Target: Target object>']
|
|
||||||
)
|
|
||||||
self.assertQuerysetEqual(
|
|
||||||
Target.objects.exclude(second_pointer=None),
|
|
||||||
[]
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_o2o_primary_key_delete(self):
|
def test_o2o_primary_key_delete(self):
|
||||||
t = Target.objects.create(name='name')
|
t = Target.objects.create(name='name')
|
||||||
|
@ -424,16 +411,10 @@ class OneToOneTests(TestCase):
|
||||||
private_director = Director.objects.create(school=private_school, is_temp=True)
|
private_director = Director.objects.create(school=private_school, is_temp=True)
|
||||||
|
|
||||||
# Only one school is available via all() due to the custom default manager.
|
# Only one school is available via all() due to the custom default manager.
|
||||||
self.assertQuerysetEqual(
|
self.assertSequenceEqual(School.objects.all(), [public_school])
|
||||||
School.objects.all(),
|
|
||||||
["<School: School object>"]
|
|
||||||
)
|
|
||||||
|
|
||||||
# Only one director is available via all() due to the custom default manager.
|
# Only one director is available via all() due to the custom default manager.
|
||||||
self.assertQuerysetEqual(
|
self.assertSequenceEqual(Director.objects.all(), [public_director])
|
||||||
Director.objects.all(),
|
|
||||||
["<Director: Director object>"]
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertEqual(public_director.school, public_school)
|
self.assertEqual(public_director.school, public_school)
|
||||||
self.assertEqual(public_school.director, public_director)
|
self.assertEqual(public_school.director, public_director)
|
||||||
|
|
Loading…
Reference in New Issue