Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#8763 closed (fixed)

modeltests/generic_relations may fail since TaggedItem ordering is not completely specified

Reported by: Richard Davies <richard.davies@…> Owned by: nobody
Component: Testing framework Version: dev
Severity: Keywords:
Cc: richard.davies@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

modeltests/generic_relations fails on one of my systems, while it works on others. The reason is that there is a test on TaggedItem.objects.all(), and the order of the items returned by all() may vary.

I attach a very simple patch to guarantee that the ordering is as expected by the test case.

The error:

$ ./runtests.py --settings=SETT_postgresql_psycopg2 generic_relations
======================================================================
FAIL: Doctest: modeltests.generic_relations.models.__test__.API_TESTS
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/elastic/django-dev/trunk/django/test/_doctest.py", line 2180, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for modeltests.generic_relations.models.__test__.API_TESTS
  File "/home/elastic/django-dev/trunk/tests/modeltests/generic_relations/models.py", line unknown line number, in API_TESTS

----------------------------------------------------------------------
File "/home/elastic/django-dev/trunk/tests/modeltests/generic_relations/models.py", line ?, in modeltests.generic_relations.models.__test__.API_TESTS
Failed example:
    [(t.tag, t.content_type, t.object_id) for t in TaggedItem.objects.all()]
Expected:
    [(u'clearish', <ContentType: mineral>, 1), (u'fatty', <ContentType: vegetable>, 2), (u'fatty', <ContentType: animal>, 1), (u'hairy', <ContentType: animal>, 2), (u'salty', <ContentType: vegetable>, 2), (u'shiny', <ContentType: animal>, 1), (u'yellow', <ContentType: animal>, 2)]
Got:
    [(u'clearish', <ContentType: mineral>, 1), (u'fatty', <ContentType: animal>, 1), (u'fatty', <ContentType: vegetable>, 2), (u'hairy', <ContentType: animal>, 2), (u'salty', <ContentType: vegetable>, 2), (u'shiny', <ContentType: animal>, 1), (u'yellow', <ContentType: animal>, 2)]
----------------------------------------------------------------------
File "/home/elastic/django-dev/trunk/tests/modeltests/generic_relations/models.py", line ?, in modeltests.generic_relations.models.__test__.API_TESTS
Failed example:
    [(t.tag, t.content_type, t.object_id) for t in TaggedItem.objects.all()]
Expected:
    [(u'clearish', <ContentType: mineral>, 1), (u'fatty', <ContentType: vegetable>, 2), (u'fatty', <ContentType: animal>, 1), (u'salty', <ContentType: vegetable>, 2), (u'shiny', <ContentType: animal>, 1)]
Got:
    [(u'clearish', <ContentType: mineral>, 1), (u'fatty', <ContentType: animal>, 1), (u'fatty', <ContentType: vegetable>, 2), (u'salty', <ContentType: vegetable>, 2), (u'shiny', <ContentType: animal>, 1)]
----------------------------------------------------------------------
File "/home/elastic/django-dev/trunk/tests/modeltests/generic_relations/models.py", line ?, in modeltests.generic_relations.models.__test__.API_TESTS
Failed example:
    [(t.tag, t.content_type, t.object_id) for t in TaggedItem.objects.all()]
Expected:
    [(u'clearish', <ContentType: mineral>, 1), (u'fatty', <ContentType: vegetable>, 2), (u'fatty', <ContentType: animal>, 1), (u'salty', <ContentType: vegetable>, 2), (u'shiny', <ContentType: animal>, 1)]
Got:
    [(u'clearish', <ContentType: mineral>, 1), (u'fatty', <ContentType: animal>, 1), (u'fatty', <ContentType: vegetable>, 2), (u'salty', <ContentType: vegetable>, 2), (u'shiny', <ContentType: animal>, 1)]


----------------------------------------------------------------------
Ran 1 test in 0.319s

FAILED (failures=1)

Attachments (1)

8763_generic_relations_sort.diff (461 bytes ) - added by Richard Davies <richard.davies@…> 16 years ago.

Download all attachments as: .zip

Change History (4)

by Richard Davies <richard.davies@…>, 16 years ago

comment:1 by Eric Holscher, 16 years ago

Triage Stage: UnreviewedAccepted

This looks ready for checkin, but I'll just mark it accepted.

comment:2 by Jacob, 16 years ago

Resolution: fixed
Status: newclosed

(In [8815]) Fixed #8763: added an explicit ordering to the generic_relations test so that the test results aren't dependant on database ordering.

comment:3 by Jacob, 13 years ago

milestone: 1.0

Milestone 1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top