Reputation: 25
I was creating sanity checks in my django tests and came across an error I had accounted for. Unfortunately my test fails when it should be successful. I am testing when a page is not there (a 404 status code). The error message and code are below. When I added quotes I received 404 is not '404'.
Django-1.10.2 & Python 3.4.5
./manage.py test app
Traceback (most recent call last):
File "/tests/dir/tests.py", line 26, in test_404
self.assertIs(response.status_code,404)
AssertionError: 404 is not 404
from django.test import TestCase
from django.test import Client
class SanityCheckTests(TestCase):
def test_404(self):
"""
Http Code 404
"""
client = Client()
response = client.get('/test404')
print(response)
self.assertIs(response.status_code,404)
Upvotes: 2
Views: 232