larken

勤奋的人生才有价值

导航

Django入门指南-第8章:第一个测试用例(完结)

python manage.py test
python manage.py test --verbosity=2
# boards/tests.py
from django.core.urlresolvers import reverse
from django.urls import resolve
from django.test import TestCase
from .views import home

class HomeTests(TestCase):
    def test_home_view_status_code(self):
        url = reverse('home')
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)

    def test_home_url_resolves_home_view(self):
        view = resolve('/')
        self.assertEquals(view.func, home)

 

posted on 2018-09-05 09:40  larken  阅读(529)  评论(0编辑  收藏  举报