我在django测试中创建了正常检查,并遇到了一个我已经解释过的错误。不幸的是,我的测试失败时,它应该是成功的。当页面不存在时,我正在测试( 404状态代码)。错误消息和代码如下所示。当我添加引号时,我收到404不是'404‘。
Django-1.10.2 &Python3.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)https://stackoverflow.com/questions/39969494
复制相似问题