Book Image

Django 1.1 Testing and Debugging

Book Image

Django 1.1 Testing and Debugging

Overview of this book

Bugs are a time consuming burden during software development. Django's built-in test framework and debugging support help lessen this burden. This book will teach you quick and efficient techniques for using Django and Python tools to eradicate bugs and ensure your Django application works correctly. This book will walk you step by step through development of a complete sample Django application. You will learn how best to test and debug models, views, URL configuration, templates, and template tags. This book will help you integrate with and make use of the rich external environment of test and debugging tools for Python and Django applications. The book starts with a basic overview of testing. It will highlight areas to look out for while testing. You will learn about different kinds of tests available, and the pros and cons of each, and also details of test extensions provided by Django that simplify the task of testing Django applications. You will see an illustration of how external tools that provide even more sophisticated testing features can be integrated into Django's framework. On the debugging front, the book illustrates how to interpret the extensive debugging information provided by Django's debug error pages, and how to utilize logging and other external tools to learn what code is doing.
Table of Contents (17 chapters)
Django 1.1 Testing and Debugging
Credits
About the Author
About the Reviewer
Preface
Index

The twill web browsing and testing tool


twill is a Python package that supports command-line interaction with web sites, primarily for testing purposes. Like the coverage and django_coverage packages, twill can be found on PyPI: http://pypi.python.org/pypi/twill. While twill offers a command-line tool for interactive use, the commands it provides are also available from a Python API, meaning it is possible to use twill from within a Django TestCase. When we do this, we essentially replace use of the Django test Client with an alternative twill implementation.

Note

Note that the latest official release of twill available on PyPI (0.9 at the time of this writing) is quite old. The latest development release is available at http://darcs.idyll.org/~t/projects/twill-latest.tar.gz. Output from the latest development release as of January 2010 is what is shown in this section. The code included here was also tested with the official 0.9 release. Everything works using the older twill code, but the...