Django 1.1 Testing and Debugging

Building rigorously tested and bug-free Django applications

Django 1.1 Testing and Debugging

Karen M. Tracey

1 customer reviews
Building rigorously tested and bug-free Django applications
Mapt Subscription
FREE
$29.99/m after trial
eBook
$21.00
RRP $29.99
Save 29%
Print + eBook
$49.99
RRP $49.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$21.00
$49.99
$29.99p/m after trial
RRP $29.99
RRP $49.99
Subscription
eBook
Print + eBook
Start 30 Day Trial
Subscribe and access every Packt eBook & Video.
 
  • 5,000+ eBooks & Videos
  • 50+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 
Preview in Mapt

Book Details

ISBN 139781847197566
Paperback436 pages

Book Description

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

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.

Authors

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

Book Details

ISBN 139781847197566
Paperback436 pages
Read More
From 1 reviews

Read More Reviews

Recommended for You

Django JavaScript Integration: AJAX and jQuery Book Cover
Django JavaScript Integration: AJAX and jQuery
$ 26.99
$ 18.90
Python 3 Object Oriented Programming Book Cover
Python 3 Object Oriented Programming
$ 29.99
$ 21.00
Responsive Web Design with HTML5 and CSS3 Book Cover
Responsive Web Design with HTML5 and CSS3
$ 23.99
$ 4.80
Mastering Web Application Development with AngularJS Book Cover
Mastering Web Application Development with AngularJS
$ 26.99
$ 5.40
Python Testing Cookbook Book Cover
Python Testing Cookbook
$ 26.99
$ 18.90
jQuery UI 1.7: The User Interface Library for jQuery  Book Cover
jQuery UI 1.7: The User Interface Library for jQuery
$ 26.99
$ 18.90