Skip to content

Commit

Permalink
Fixed #21403: Corrected test code
Browse files Browse the repository at this point in the history
A test for annotations incorrectly assumed that the first instance
(in the test) of a model using AutoField for PK will always get pk=1.
The test was changed to compare against actual instance id instead.
  • Loading branch information
shaib committed Nov 25, 2013
1 parent 70e6131 commit 3411af3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/generic_relations_regress/tests.py
Expand Up @@ -222,10 +222,10 @@ def test_annotate(self):
Link.objects.create(content_object=b)
qs = HasLinkThing.objects.annotate(Sum('links'))
# If content_type restriction isn't in the query's join condition,
# then wrong results are produced here as b will also match (it has
# same pk).
# then wrong results are produced here as the link to b will also match
# (b and hs1 have equal pks).
self.assertEqual(qs.count(), 1)
self.assertEqual(qs[0].links__sum, 1)
self.assertEqual(qs[0].links__sum, l.id)
l.delete()
# Now if we don't have proper left join, we will not produce any
# results at all here.
Expand Down

0 comments on commit 3411af3

Please sign in to comment.