I'm using SimpleTestCase to test my website in Django but only pass 2 of 4
I tried using this but still did not work
This is my tests.py
from django.test import SimpleTestCase
class PageTest(SimpleTestCase):
def test_portfolio_page_status_code(self):
response = self.client.get("/portfolio")
self.assertEquals(response.status_code, 200)
def test_blog_page_status_code(self):
response = self.client.get("/blog")
self.assertEqual(response.status_code, 200)
def test_home_page_status_code(self):
response = self.client.get("")
self.assertEquals(response.status_code, 200)
def test_quotes_page_status_code(self):
response = self.client.get("/quotes/")
self.assertEquals(response.status_code, 200)
The traceback is:
======================================================================
FAIL: test_blog_page_status_code (personal_portfolio.tests.PageTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/user/dir/personal_portfolio/tests.py", line
11, in test_blog_page_status_code
self.assertEqual(response.status_code, 200)
AssertionError: 301 != 200
======================================================================
FAIL: test_portfolio_page_status_code
(personal_portfolio.tests.PageTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/user/dir/personal_portfolio/tests.py", line
7, in test_portfolio_page_status_code
self.assertEquals(response.status_code, 200)
AssertionError: 301 != 200
Where do you think I got this wrong?
Aucun commentaire:
Enregistrer un commentaire