python Web开发:测试驱动方法---3.3.django中的单元测试,3.4MVC、URL和视图函数:
tests.py测试类中写的第一个单元测试函数,如下: class HomePageTest(TestCase): def test_root_url_resolves_to_home_page_view(self): #print "befor exct found" found = resolve('/') #print "befor exct found:",found self.assertEqual(found.func, home_page)
执行后报404错误
Traceback (most recent call last):
File "E:\djangoPreject\HelloWorld\cmdb\tests.py", line 11, in test_root_url_resolves_to_home_page_view
found = resolve('/')
File "C:\Python27\lib\site-packages\django\urls\base.py", line 27, in resolve
return get_resolver(urlconf).resolve(path)
File "C:\Python27\lib\site-packages\django\urls\resolvers.py", line 394, in resolve
raise Resolver404({'tried': tried, 'path': new_path})
Resolver404: {u&#