Free Sample
+ Collection

Django 1.1 Testing and Debugging

Starting
Karen M. Tracey

Building rigorously tested and bug-free Django applications
$29.99
$49.99
RRP $29.99
RRP $49.99
eBook
Print + eBook

Want this title & more?

$12.99 p/month

Subscribe to PacktLib

Enjoy full and instant access to over 2000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Book Details

ISBN 139781847197566
Paperback436 pages

About This Book

Develop Django applications quickly with fewer bugs through effective use of automated testing and debugging tools. Ensure your code is accurate and stable throughout development and production by using Django's test framework. Understand the working of code and its generated output with the help of debugging tools. Packed with detailed working examples that illustrate the techniques and tools for debugging

Who This Book Is For

If you are a Django application developer who wants to create robust applications quickly that work well and are easy to maintain in the long term, this book is for you. This book is the right pick if you want to be smartly tutored to make best use of Django's rich testing and debugging support and make testing an effortless task.Basic knowledge of Python, Django, and the overall structure of a database-driven web application is assumed. However, the code samples are fully explained so that even beginners who are new to the area can learn a great deal from this book.

Table of Contents

Chapter 1: 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
Chapter 2: Does This Code Work? Doctests in Depth
The Survey application models
Testing the Survey model
Additional doctest caveats
Summary
Chapter 3: 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
Chapter 4: 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
Chapter 5: 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
Chapter 6: Django Debugging Overview
Django debug settings
Debug error pages
Database query history
Debug support in the development server
Handling problems in production
Summary
Chapter 7: 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
Chapter 8: When Problems Hide: Getting More Information
Tracking SQL queries for a request
The Django Debug Toolbar
Tracking internal code state
Summary
Chapter 9: 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
Chapter 10: When All Else Fails: Getting Outside Help
Tracking down a problem in Django
Tracking down unreported problems
Summary
Chapter 11: 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

What You Will Learn

Build a complete application in manageable pieces that can be written, tested, and debugged individually. Come to grips with the nuances of testing and the pros and cons of each type of test Simplify the task of testing web applications by using specific test extensions provided by Django. Integrate other test tools into Django's framework to obtain test coverage information and more easily test forms. Analyze the copious debug information provided by Django's debug error pages. Write your own add-on debugging aids. Easily acquire enormous and important information with the help of external tools such as the Django debug toolbar. Decipher code behavior by using logging and effectively debug problems in production, when debug error pages are not available. Learn what your code and other library support code actually does by skilled use of a debugger. Tackle problems external to your code with available fixes. Debug common problems that arise during the move from development to production.

In Detail

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.

Authors

Read More

Recommended for You

Web Development with Django Cookbook
$ 29.99
Django Essentials
$ 13.99
Instant Django 1.5 Application Development Starter
$ 12.99
Django JavaScript Integration: AJAX and jQuery
$ 26.99