Evander Nassem Ramírez Hernández
PreguntaAYUDA, HE INTENTADO DE TODO PERO NIO SÉ QUE ESTÁ MAL 😦
Traceback (most recent call last): File "C:\Users\Lennox\Documents\Cursos Back End Developer\mejorCursoProgramacion\mejorCursoProgramacion\polls\tests.py", line 130, in test_future_question self.assertContains(response, "No polls are available") File "C:\Users\Lennox\AppData\Local\Programs\Python\Python310\lib\site-packages\django\test\testcases.py", line 658, in assertContains self.assertTrue( AssertionError: False is not true : Couldn't find 'No polls are available' in response ====================================================================== FAIL: test_no_questions (polls.tests.QuestionIndexViewTests) If no question exist, an appropiate message is displayed. ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\Users\Lennox\Documents\Cursos Back End Developer\mejorCursoProgramacion\mejorCursoProgramacion\polls\tests.py", line 111, in test_no_questions self.assertContains(response, "No polls are available") File "C:\Users\Lennox\AppData\Local\Programs\Python\Python310\lib\site-packages\django\test\testcases.py", line 658, in assertContains self.assertTrue( AssertionError: False is not true : Couldn't find 'No polls are available' in response

Paulo Emanuel Tintaya Conde
Hola, yo tenia el mismo error. Podrias revisar si en templates/index.html este el mismo texto de "No polls are available." ya que como el assertContains busca que contenga ese texto pues no lo encuentra y por eso te sale el error. Bueno ese podrias ser el error talvez, te dejo parte de mi codigo para que lo compares 😅 Espero te sea de ayuda
templates/index.html
{% if latest_question_list %} <ul> {% for question in latest_question_list %} <li><a href="{%url 'polls:detail' question.id %}">{{ question.question_text }}</a></li> {% endfor %} </ul> {% else %} <p>No polls are available.</p> {% endif %}
archivo test.py🐍
class QuestionIndexViewTests(TestCase): def test_no_questions(self): """If no question exist, an appropiate message is displayed.""" response = self.client.get(reverse('polls:index')) self.assertEqual(response.status_code, 200) self.assertContains(response, "No polls are available.") self.assertQuerysetEqual(response.context['latest_question_list'], []) def test_past_question(self): """Questions with a pub_date in the past are displayed on the index page.""" question = create_question(question_text="Past question.", days=-30) response = self.client.get(reverse('polls:index')) self.assertQuerysetEqual( response.context['latest_question_list'], [question], ) def test_future_question(self): """ Questions with a pub_date in the future aren't displayed on the index page. """ create_question(question_text="Future question.", days=30) response = self.client.get(reverse('polls:index')) self.assertContains(response, "No polls are available.") self.assertQuerysetEqual(response.context['latest_question_list'], [])