Background Image
Table of Contents Table of Contents
Previous Page  73 / 478 Next Page
Information
Show Menu
Previous Page 73 / 478 Next Page
Page Background

Figure 4-2. Refactoring Cat—be sure to look up the full animated GIF (source:

4GIFs.com)

We’ll come across “Refactoring Cat” again during this book, as an

example of what happens when we get carried away and want to

change toomany things at once. Think of it as the little cartoon demon

counterpart to the Testing Goat, popping up over your other shoul‐

der and giving you bad advice…

It’s a good idea to do a commit after any refactoring:

$

git status

# see tests.py, views.py, settings.py, + new templates folder

$

git add .

# will also add the untracked templates folder

$

git diff --staged

# review the changes we're about to commit

$

git commit -m"Refactor home page view to use a template"

A Little More of Our Front Page

In the meantime, our functional test is still failing. Let’s nowmake an actual code change

to get it passing. Because our HTML is now in a template, we can feel free to make

changes to it, without needing to write any extra unit tests. We wanted an

<h1>

:

lists/templates/home.html.

<html>

<head>

<title>

To-Do lists

</title>

</head>

<body>

<h1>

Your To-Do list

</h1>

</body>

</html>

Let’s see if our functional test likes it a little better:

A Little More of Our Front Page

|

45