3.5.1 Teste de Unidade de uma View
from django.urls import resolve
from django.test import TestCase
from django.http import HttpRequest
from lists.views import home_page
class HomePageTest(TestCase):
def test_root_url_resolves_to_home_page_view(self):
found = resolve('/')
self.assertEquals(found.func, home_page)
def test_home_page_returns_correct_html(self):
request = HttpRequest()
response = home_page(request)
html = response.content.decode('utf-8')
self.assertTrue(html.startswith('<html>'))
self.assertIn('<title>To-Do lists</title>', html)
self.assertTrue(html.endswith('</html>'))Alteração mínima no código lists/views.py
Resultado dos testes lists/tests.py
Alteração mínima no código lists/views.py
Resultado dos testes lists/tests.py
Alteração mínima no código lists/views.py
Resultado dos testes lists/tests.py
Alteração mínima no código lists/views.py
Resultado dos testes lists/tests.py
Alteração mínima no código lists/views.py
Resultado dos testes lists/tests.py
Last updated