Cover image for Django 1.1 Testing and Debugging.
Django 1.1 Testing and Debugging.
Title:
Django 1.1 Testing and Debugging.
Author:
Tracey, Karen M.
ISBN:
9781847197573
Personal Author:
Physical Description:
1 online resource (430 pages)
Contents:
Django 1.1 Testing and Debugging -- Table of Contents -- Django 1.1 Testing and Debugging -- Credits -- About the Author -- About the Reviewer -- Preface -- What this book covers -- What you need for this book -- Who this book is for -- Conventions -- Reader feedback -- Customer support -- Errata -- Piracy -- Questions -- 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 -- Verbosity -- Settings -- Pythonpath -- Traceback -- Noinput -- Version -- Summary -- 2. Does This Code Work? Doctests in Depth -- The Survey application models -- Testing the Survey model -- Testing Survey model creation -- Is that test useful? -- Developing a custom Survey save method -- Deciding what to test -- Some pros and cons of doctests so far -- Additional doctest caveats -- Beware of environmental dependence -- Beware of database dependence -- Beware of test interdependence -- Beware of Unicode -- Summary -- 3. Testing 1, 2, 3: Basic Unit Testing -- Unit tests for the Survey save override method -- Pros of the unit test version -- Cons of the unit test version -- Revisiting the doctest caveats -- Environmental dependence -- Database dependence -- Test interdependence -- Unicode -- Providing data for unit tests -- Providing data in test fixtures -- Example test that needs test data -- Using the admin application to create test data -- Writing the function itself -- Writing a test that uses the test data -- Extracting the test data from the database -- Getting the test data loaded during the test run -- Creating data during test set up -- Summary -- 4. Getting Fancier: Django Unit Test Extensions -- Organizing tests.

Creating the survey application home page -- Defining the survey application URLs -- Developing views to serve pages -- Creating templates for pages -- Testing the survey home page -- Creating the survey detail pages -- Refining the survey detail view -- Templates for the survey detail pages -- Basic testing of the survey detail pages -- Customizing the admin add and change survey pages -- Developing a custom survey form -- Configuring admin to use the custom form -- Testing the admin customization -- Additional test support -- Supporting additional HTTP methods -- Maintaining persistent state -- E-mail services -- Providing test-specific URL configuration -- Response context and template information -- Testing transactional behavior -- Summary -- 5. Filling in the Blanks: Integrating Django and Other Test Tools -- Problems of integration -- Specifying an alternative test runner -- Creating a new management command -- How much of the code are we testing? -- Using coverage standalone -- Integrating coverage into a Django project -- The twill web browsing and testing tool -- Using the twill command line program -- Using twill in a TestCase -- Summary -- 6. Django Debugging Overview -- Django debug settings -- The DEBUG and TEMPLATE_DEBUG settings -- The TEMPLATE_STRING_IF_INVALID setting -- Debug error pages -- Database query history -- Debug support in the development server -- Handling problems in production -- Creating general error pages -- Reporting production error information -- Internal server error notifications -- Page not found notifications -- Summary -- 7. When the Wheels Fall Off: Understanding a Django Debug Page -- Starting the Survey voting implementation -- Creating test data for voting -- Defining a question form for voting -- Debug page #1: TypeError at / -- Elements of the debug page -- Basic error information -- Traceback.

Request information -- GET -- POST -- FILES -- COOKIES -- META -- Settings -- Understanding and fixing the TypeError -- Handling multiple Survey questions -- Creating the data for multiple questions -- Coding support for multiple questions -- Debug page #2: TemplateSyntaxError at /1/ -- Understanding and fixing the TemplateSyntaxError -- Recording Survey responses -- Coding support for recording Survey responses -- Debug page #3: NoReverseMatch at /1/ -- Understanding and fixing the NoReverseMatch exception -- Debug page #4: TemplateDoesNotExist at /thanks/1/ -- Understanding and fixing TemplateDoesNotExist -- Handling invalid Survey submissions -- Coding custom error message and placement -- Debug page #5: Another TemplateSyntaxError -- Fixing the second TemplateSyntaxError -- Summary -- 8. When Problems Hide: Getting More Information -- Tracking SQL queries for a request -- Settings for accessing query history in templates -- SQL queries for the home page -- Packaging the template query display for reuse -- Testing the repackaged template code -- SQL queries for the active Survey form display page -- SQL queries for posting survey answers -- The Django Debug Toolbar -- Installing the Django Debug Toolbar -- Debug toolbar appearance -- The SQL panel -- The Time panel -- The Settings panel -- The HTTP Headers panel -- The Request Vars panel -- The Templates panel -- The Signals panel -- The Logging panel -- Redirect handling by the debug toolbar -- Tracking internal code state -- Resist the urge to sprinkle prints -- Simple logging configuring for development -- Deciding what to log -- Decorators to log function entry and exit -- Applying the decorators to the Survey code -- Logging in the debug toolbar -- Summary -- 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 -- The list command -- The where command -- The args command -- The whatis command -- The print and pp commands -- Debugging the pygooglechart results display -- The step and next commands -- The continue command -- The jump command -- The break command -- The clear command -- Fixing the pygooglechart results display -- The up and down commands -- The return command -- Results display using matplotlib -- Improving the matplotlib approach -- Setting up static file serving -- Dynamically generating image files -- Dealing with race conditions -- Using the debugger to force race situations -- Notes on using graphical debuggers -- Summary -- 10. When All Else Fails: Getting Outside Help -- Tracking down a problem in Django -- Revisiting the Chapter 7 voting form -- Is the right code actually running? -- Is the code correct as per the documentation? -- Searching for a matching problem report -- Another way to search for a matching problem report -- Determining the release that contains a fix -- What if a fix hasn't been released yet? -- What if a fix hasn't been committed yet? -- What if a ticket has been closed without a fix? -- Tracking down unreported problems -- Where to ask questions -- Tips on asking questions that will get good answers -- Opening a new ticket to report a problem -- Summary -- 11. When it's Time to Go Live: Moving to Production -- Developing an Apache/mod_wsgi configuration -- Creating the WSGI script for the marketr project -- Creating an Apache VirtualHost for the marketr project -- Activating the new Apache configuration -- Debugging the new Apache configuration -- Configuring Apache to serve static files -- Testing multithreaded behavior -- Generating load with siege -- Load testing the results recording code -- Fixing the results recording code.

Additional load testing notes -- Using Apache/mod_wsgi during development -- Summary -- Index.
Abstract:
This book teaches by example. It walks in detail through development of a sample application, illustrating each step via complete working code and either screenshots or console snippets. The cumbersome and time consuming task of debugging will be a cake walk with this book. 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.
Local Note:
Electronic reproduction. Ann Arbor, Michigan : ProQuest Ebook Central, 2017. Available via World Wide Web. Access may be limited to ProQuest Ebook Central affiliated libraries.
Electronic Access:
Click to View
Holds: Copies: