我想在django中測試我的網址,但我收到了錯誤消息。如何在django中測試網址
這裏是我的代碼:
urls.py
url(r'^create/(?P<userName>[0-9a-zA-Z-]+)/$', views.create, name='create'),
test.py
from django.test import TestCase, Client
client = Client()
def test_create(self):
"""Test the url for "create"
"""
response = self.client.get('/mission/create/' + str(self.userName))
self.assertEqual(response.status_code, 200)
,我會得到這樣的結果:
FAIL: test_create (mission.tests.MissionUrlTests)
Test the url for "create"
----------------------------------------------------------------------
Traceback (most recent call last):
File "/actinbox/mission/tests.py", line 122, in test_create
self.assertEqual(response.status_code, 200)
AssertionError: 301 != 200
請幫我與我的代碼在這裏。先謝謝你。
謝謝你這麼多......現在已經工作! :) –