[Django] #23654: test_index_view_with_two_past_questions() raising ValueError

15 views
Skip to first unread message

Django

unread,
Oct 14, 2014, 12:09:30 PM10/14/14
to django-...@googlegroups.com
#23654: test_index_view_with_two_past_questions() raising ValueError
-------------------------------+--------------------
Reporter: skalrynd | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
While following tutorial 5 and executing the test at:
https://docs.djangoproject.com/en/1.7/intro/tutorial05/

I got a raised exception:

{{{
Traceback (most recent call last):
File "/var/www/project.com/project/polls/tests.py", line 97, in
test_index_view_with_two_past_questions
['<Question: Past question 2.>', '<Question: Past question 1.>']
File "/usr/local/lib/python3.4/dist-packages/django/test/testcases.py",
line 853, in assertQuerysetEqual
raise ValueError("Trying to compare non-ordered queryset "
ValueError: Trying to compare non-ordered queryset against more than one
ordered values
}}}


I found the error to be resolved using list():

{{{
def test_index_view_with_two_past_questions(self):
"""
The questions index page may display multiple questions.
"""
create_question(question_text="Past question 1.", days=-30)
create_question(question_text="Past question 2.", days=-5)
response = self.client.get(reverse('polls:index'))
self.assertQuerysetEqual(
list(response.context['latest_question_list']),
list(['<Question: Past question 2.>', '<Question: Past
question 1.>'])
)
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23654>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 14, 2014, 12:36:40 PM10/14/14
to django-...@googlegroups.com
#23654: test_index_view_with_two_past_questions() raising ValueError
-------------------------------+--------------------------------------

Reporter: skalrynd | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by bmispelon):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Hi,

Are you using the same view as the one defined in part 4 [1]?

Those define the queryset as `Question.objects.order_by('-pub_date')[:5]`
so that error message should not get triggered.

Thanks.

[1] https://docs.djangoproject.com/en/1.7/intro/tutorial04/#amend-views

--
Ticket URL: <https://code.djangoproject.com/ticket/23654#comment:1>

Django

unread,
Oct 14, 2014, 1:23:58 PM10/14/14
to django-...@googlegroups.com
#23654: test_index_view_with_two_past_questions() raising ValueError
-------------------------------+--------------------------------------
Reporter: skalrynd | Owner: nobody
Type: Uncategorized | Status: closed
Component: Documentation | Version: 1.7
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by skalrynd):

* status: new => closed
* resolution: => invalid


Comment:

That resolved it.

--
Ticket URL: <https://code.djangoproject.com/ticket/23654#comment:2>

Reply all
Reply to author
Forward
0 new messages