Hi, I have encountered a difficulty in one of tutorial 5’s automated tests (9 of the 10 tests pass, but this test fails). The test_two_past_questions(self):
fails for me with the following error in the command line:
Traceback (most recent call last):
File "/workspace/pp4-django-blog/poll/tests.py", line 104, in test_two_past_questions
self.assertQuerysetEqual(
File "/workspace/.pip-modules/lib/python3.8/site-packages/django/test/testcases.py", line 1072, in assertQuerysetEqual
return self.assertEqual(list(items), values, msg=msg)
AssertionError: Lists differ: [<Question: Past question 1.>, <Question: Past question 2.>] != [<Question: Past question 2.>, <Question: Past question 1.>]
First differing element 0:
<Question: Past question 1.>
<Question: Past question 2.>
- [<Question: Past question 1.>, <Question: Past question 2.>]
? ^ ^
+ [<Question: Past question 2.>, <Question: Past question 1.>]
? ^ ^
The test code I have is pasted below (matches to the tutorial test code):
def test_two_past_questions(self):
"""
The questions index page may display multiple questions.
"""
question1 = create_question(question_text="Past question 1.", days=-30)
question2 = create_question(question_text="Past question 2.", days=-5)
response = self.client.get(reverse('poll:index'))
self.assertQuerysetEqual(
response.context['latest_question_list'],
[question2, question1],
)
And when I load my polls page/index.html, it does display multiple questions, so I am not sure how to resolve this
Thanks in advance for any clarifications you may be able to provide