Test-Driven Development with Python
- Length: 480 pages
- Edition: 1
- Language: English
- Publisher: O'Reilly Media
- Publication Date: 2014-06-29
- ISBN-10: 1449364829
- ISBN-13: 9781449364823
- Sales Rank: #391345 (See Top 100 Books)
By taking you through the development of a real web application from beginning to end, this hands-on guide demonstrates the practical advantages of test-driven development (TDD) with Python. You’ll learn how to write and run tests before building each part of your app, and then develop the minimum amount of code required to pass those tests. The result? Clean code that works.
In the process, you’ll learn the basics of Django, Selenium, Git, jQuery, and Mock, along with current web development techniques. If you’re ready to take your Python skills to the next level, this book clearly demonstrates how TDD encourages simple designs and inspires confidence.
- Dive into the TDD workflow, including the unit test/code cycle and refactoring
- Use unit tests for classes and functions, and functional tests for user interactions within the browser
- Learn when and how to use mock objects, and the pros and cons of isolated vs. integrated tests
- Test and automate your deployments with a staging server
- Apply tests to the third-party plugins you integrate into your site
- Use a Continuous Integration environment to run your tests automatically
Table of Contents
Part I. The Basics of TDD and Django
Chapter 1. Getting Django Set Up Using a Functional Test
Chapter 2. Extending Our Functional Test Using the unittest Module
Chapter 3. Testing a Simple Home Page with Unit Tests
Chapter 4. What Are We Doing with All These Tests?
Chapter 5. Saving User Input
Chapter 6. Getting to the Minimum Viable Site
Part II. Web Development Sine Qua Nons
Chapter 7. Prettification: Layout and Styling, and What to Test About It
Chapter 8. Testing Deployment Using a Staging Site
Chapter 9. Automating Deployment with Fabric
Chapter 10. Input Validation and Test Organisation
Chapter 11. A Simple Form
Chapter 12. More Advanced Forms
Chapter 13. Dipping Our Toes, Very Tentatively, into JavaScript
Chapter 14. Deploying Our New Code
Part III. More Advanced Topics
Chapter 15. User Authentication, Integrating Third-Party Plugins, and Mocking with JavaScript
Chapter 16. Server-Side Authentication and Mocking in Python
Chapter 17. Test Fixtures, Logging, and Server-Side Debugging
Chapter 18. Finishing “My Lists”: Outside-In TDD
Chapter 19. Test Isolation, and “Listening to Your Tests”
Chapter 20. Continuous Integration (CI)
Chapter 21. The Token Social Bit, the Page Pattern, and an Exercise for the Reader
Chapter 22. Fast Tests, Slow Tests, and Hot Lava
Appendix A. PythonAnywhere
Appendix B. Django Class-Based Views
Appendix C. Provisioning with Ansible
Appendix D. Testing Database Migrations
Appendix E. What to Do Next
Appendix F. Cheat Sheet
Appendix G. Bibliography