Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Test Driven Python Development

You're reading from   Test Driven Python Development Develop high-quality and maintainable Python applications using the principles of test-driven development

Arrow left icon
Product type Paperback
Published in Apr 2015
Publisher Packt
ISBN-13 9781783987924
Length 264 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Siddharta Govindaraj Siddharta Govindaraj
Author Profile Icon Siddharta Govindaraj
Siddharta Govindaraj
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Getting Started with Test-Driven Development FREE CHAPTER 2. Red-Green-Refactor – The TDD Cycle 3. Code Smells and Refactoring 4. Using Mock Objects to Test Interactions 5. Working with Legacy Code 6. Maintaining Your Test Suite 7. Executable Documentation with doctest 8. Extending unittest with nose2 9. Unit Testing Patterns 10. Tools to Improve Test-Driven Development A. Answers to Exercises B. Working with Older Python Versions Index

What this book covers

Chapter 1, Getting Started with Test-Driven Development, is the introductory chapter. It eases you into the TDD process by setting the context of why we need TDD and quickly getting started with a test.

Chapter 2, Red-Green-Refactor – The TDD Cycle, goes deeper into the TDD process, driving the implementation of our example project as we write more tests.

Chapter 3, Code Smells and Refactoring, explores common types of smelly code, and we go back to our example project and clean up the smells we find. A key benefit of TDD is that it provides a safety net so that we can go in and clean up messy code.

Chapter 4, Using Mock Objects to Test Interactions, shows the use of mocking to implement the parts of our example project that depend on other systems. How do you test code that depends on external subsystems? We answer that question here by introducing mock objects.

Chapter 5, Working with Legacy Code, is about the fact that we often need to clean up or add features to old code that doesn't have existing tests. This chapter looks at strategies for doing this by working through one of the modules in our sample application.

Chapter 6, Maintaining Your Test Suite, proves that unit tests are also code and good coding practices apply to test code as well. This means keeping them well organized and easy to maintain. This chapter covers techniques to do just that.

Chapter 7, Executable Documentation with doctest, goes through the usage of doctest by working through one of the modules of our application.

Chapter 8, Extending unittest with nose2, gives us a look at nose2, a powerful test runner and plugin suite that extends the unittest framework.

Chapter 9, Unit Testing Patterns, covers some other patterns for unit testing. We see how to speed up tests and how we can run specific subsets of tests. We also take a look at data-driven tests and mocking patterns.

Chapter 10, Tools to Improve Test-Driven Development, explains some popular third-party tools to help us improve our TDD practice. Some of these tools, such as py.test and trial, are test runners with some unique features.

Appendix A, Answers to Exercises, contains the answers to the exercises presented throughout this book. There are many possible solutions, each with their own advantages and disadvantages.

Appendix B, Working with Older Python Versions, describes the changes needed in order to apply the techniques in this book for older versions of Python because this book has been written for Python 3.4.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime
Visually different images