PacktLib: Django 1.1 Testing and Debugging

Django 1.1 Testing and Debugging

Credits

About the Author

About the Reviewer

Preface

Django Testing Overview

Getting started: Creating a new application

Understanding the sample unit test

Understanding the sample doctest

Running the sample tests

Breaking things on purpose

Test errors versus test failures

Command line options for running tests

Summary

Does This Code Work? Doctests in Depth

The Survey application models

Testing the Survey model

Additional doctest caveats

Summary

Testing 1, 2, 3: Basic Unit Testing

Unit tests for the Survey save override method

Revisiting the doctest caveats

Providing data for unit tests

Summary

Getting Fancier: Django Unit Test Extensions

Organizing tests

Creating the survey application home page

Creating the survey detail pages

Customizing the admin add and change survey pages

Additional test support

Testing transactional behavior

Summary

Filling in the Blanks: Integrating Django and Other Test Tools

Problems of integration

How much of the code are we testing?

The twill web browsing and testing tool

Summary

Django Debugging Overview

Django debug settings

Debug error pages

Database query history

Debug support in the development server

Handling problems in production

Summary

When the Wheels Fall Off: Understanding a Django Debug Page

Starting the Survey voting implementation

Elements of the debug page

Understanding and fixing the TypeError

Handling multiple Survey questions

Recording Survey responses

Handling invalid Survey submissions

Summary

When Problems Hide: Getting More Information

Tracking SQL queries for a request

The Django Debug Toolbar

Tracking internal code state

Summary

When You Don't Even Know What to Log: Using Debuggers

Implementing the Survey results display

Results display using pygooglechart

Getting started with the debugger

Debugging the pygooglechart results display

Fixing the pygooglechart results display

Results display using matplotlib

Improving the matplotlib approach

Notes on using graphical debuggers

Summary

When All Else Fails: Getting Outside Help

Tracking down a problem in Django

Tracking down unreported problems

Summary

When it's Time to Go Live: Moving to Production

Developing an Apache/mod_wsgi configuration

Testing multithreaded behavior

Using Apache/mod_wsgi during development

Summary

Index