This code works fine in the shell, but if you run it through python manage.py test
it throws a 404 error, what could be the problem?
test_urls.py
from django.test import Client, TestCase
class StaticURLTests(TestCase):
def setUp(self):
self.guest_client = Client()
def test_homepage(self):
response = self.guest_client.get("/")
self.assertEqual(response.status_code, 200)
error:
❯ python manage.py test
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
F
======================================================================
FAIL: test_homepage (posts.tests.test_urls.StaticURLTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/finegorko/Development/Yandex.Practicum/hw03_forms/yatube/posts/tests/test_urls.py", line 10, in test_homepage
self.assertEqual(response.status_code, 200)
AssertionError: 404 != 200
----------------------------------------------------------------------
Ran 1 test in 0.003s
FAILED (failures=1)
Destroying test database for alias 'default'...