Test-driven development is a good practice. By writing your tests before the code, you solidify in your mind what the code really needs to do and whether it's structured to do what you want.
Even if you don't write tests first, having automated tests can be a lifesaver when it comes time to change things around later on.
When you install TurboGears, you also get Nose for free. Nose is a powerful and convenient test runner.
A separate document will cover testing in detail. Here's a sample controllers.py:
Nose looks for modules that start with test_. By convention, test modules go into separate packages called "tests" located beneath the package they are testing, though Nose does not require this. Here is a simple test module for the class above:
Notice that these tests are just functions, and not unittest.TestCases. You can freely use unittest.TestCases also, if you prefer. Test functions must begin with "test". The docstring provides nicer output in the testrunner.
The template test assumes that the welcome template contains something like: "The new value is $${newvalue}."
To run the tests, you just run:
nosetests
The template test goes through CherryPy's request handling machinery, so you can test everything from URL traversal to filters to template processing.