Skip to content

Instantly share code, notes, and snippets.

@xiantail
Created December 31, 2015 08:15
Show Gist options
  • Save xiantail/f95f65860abe97179d2c to your computer and use it in GitHub Desktop.
Save xiantail/f95f65860abe97179d2c to your computer and use it in GitHub Desktop.
TDD with Python / Chapter 3 extended tests.py
from django.core.urlresolvers 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_solves_to_home_page_view(self):
found = resolve('/')
self.assertEqual(found.func, home_page)
def test_home_page_returns_correct_html(self):
request = HttpRequest()
response = home_page(request)
self.assertTrue(response.content.startswith(b'<html>')) #3
self.assertIn(b'<title>To-Do lists</title>', response.content) #4
self.assertTrue(response.content.endswith(b'</html>')) #5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment