Jump to ratings and reviews
Rate this book

Learning Python Testing

Rate this book
A straightforward and easy approach to testing your Python projectsAbout This BookDevelop your knowledge and skills to increase your confidence in tackling new challengesGuides you through the tools of automated testing in Python 3 with practical and real-life examplesShows you step by step how to turn testing from a burden into a benefitWho This Book Is ForThis book is ideal if you want to learn about the testing disciplines and automated testing tools from a hands-on, conversational guide. You should already know Python and be comfortable with Python 3.

What You Will LearnMake testing easy and convenient with powerful tools such as doctest, unittest, and NoseWalk through the test-driven development process step by stepTranslate specification documents into actionable testsWrite tests that highlight exactly where a bug residesBuild on the basis of unit testing to be able to test a complete software systemUse unit testing to drive development and discover how this can make the process fasterIn DetailAutomated testing is the best way to increase efficiency and decrease the defects of software testing. It takes away much of the effort on your part so that you can find bugs early and easily. The Python unit testing framework makes it easy to write efficient automated test cases in Python. Applications involving many paradigms and styles can be very complicated to test, but with the right tools, testing becomes the simplest part of the development process.

This book starts with a short introduction to testing, and then introduces the doctest tool, both in terms of practicalities and how it fits into the testing environment. From there, the discussion proceeds to unittest.mock and mock objects, and to unittest. Next, Nose is introduced and discussed. Later on, focus turns from the tools themselves toward best practices and disciplines of testing. Finally, the integration of testing with existing build processes and toolchains is covered. By the end of this book, you will know how to use automated testing quickly and easily and in a way that helps catch bugs early and fix them.

202 pages, Kindle Edition

First published November 25, 2014

1 person is currently reading
16 people want to read

About the author

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
2 (13%)
4 stars
8 (53%)
3 stars
3 (20%)
2 stars
1 (6%)
1 star
1 (6%)
Displaying 1 - 7 of 7 reviews
Profile Image for Ivan Idris.
Author 14 books26 followers
January 11, 2015
Learning Python Testing by Daniel Arbuckle published in November 2014 by Packt Publishing, is as far as I know a second edition of sorts of another book (published in 2010) by the same author and publisher. I haven’t read the other book, but if I understand correctly there have been radical changes such as the switch to Python 3. The book has the following 9 chapters:

Python and Testing is a an introductory chapter, which describes the different types of testing. I missed the concept of the Pyramid of testing in this chapter.
Working with doctest is the first chapter of two chapter on doctest. It also talks about AVL trees, which you may want to familiarize yourself with to understand the test examples.
Unit Testing with doctest is the second chapter on doctest and it also goes deeper into unit testing.
Decoupling Units with unittest.mock introduces mocks.
Structured Testing with unittest continues the discussion of unit tests.
Running Your Tests with Nose covers installing and using Nose.
Test-driven Development Walk-through gives a fully worked out example of a personal planner project.
Integration and System Testing goes into higher level testing. Personally, I am not a fan of this level of testing. In my humble opinion, the author could have elaborated more about the circumstances when this type of testing is appropriate.
Other Tools and Techniques gives an overview of continuous integration and related tools.

Learning Python Testing uses non-trivial examples complete with test specifications and background information. I had trouble reading the output of some of the test scripts, because they were given as screenshots. The author gives a good overview of Python testing tools with some omissions such as BDD. Overall the book lived up to my expectations.
2 reviews
December 30, 2014
The testing frameworks covered are already covered in comprehensive python texts but instead of only high level overview, this textbook covers various testing frameworks and approaches in detailed manner.
The first chapter covers various forms of testing - something which could be covered in few subtopics and test driven development could have been discussed in greater detail. It then moves into doctest, which is unique approach in python and was discussed in depth - I've only known it vagely before and the provided details opened up a sea of possibilities for me. For instance, the AVL tree example provided an excellent demonstration of doctests and is worth quoting. The next chapter provided unit tests with doctest and correctly explained the essence of unit testing. The PID controller example however was confusing and it took me frequently eyeballing the code - the logic used was complicated and consequently the test cases were larger. Next, mock objects were detailed - which are not present in other python texts. unittest.mock library in python3 was explained in depth before covering the details of this module. In the next chapter, the Nose test runner was discussed and its various customizations were also explained.
Test Driven Development was introducted relatively late in the book after all the testing frameworks were covered and covered writing specification and tests before code. For someone new to TDD philosophy, this book offers excellent introduction and covers all its facets and challenging the reader to do more - which I found as a pleasant surprise. This was followed by integration and system testing doctrine. The final chapter covering importance of testing in code coverage, version control and continuous integration wrapped up this handy textbook sufficiently.

Apart from some places where I found the text opinionated with the example taken, I enjoyed the rest of the book and specially places where the reader is asked to get off reading and try things to test his/her knowledge of the topic.

Disclaimer: I received a copy of this book[http://bit.ly/1HKQaIj] for doing its review.
This entire review has been hidden because of spoilers.
Profile Image for Marc-anthony Taylor.
8 reviews
March 2, 2015
I love programming, I wouldn't say I am a great programmer but I am more than willing to learn. Perhaps because of how I came to code one of my main problems is testing. I never spent much time on it and now I often get frustrated and want to move on. This is not so good.

So i decided to have a look at "Learning Python Testing" by Daniel Arbuckle (from Packt Publishing).

The book starts slowly giving a brief overview of testing in general then using doctest in particular. I have to admit this came across as rather dry and made for rough going at the beginning.

From the third chapter things begin to pick up pace with better examples and a more hands on feel. Unit testing is the main focus of the book --although other methods are mentioned-- and it pays off. From using doctest to implement unit tests to using the actual unittest module you get a good feel for the method.

Chapter 7 is where it really took off for me. You are encouraged to create your own project to follow the chapter with. This is a chance to really implement what you have learned and gives you a more proactive feeling.

The last two chapters discuss other types of testing --integration and system-- along with other tools that may prove useful.

At the end of the book I still don't feel that I am as good a tester as I should be but I have definitely taken a step or two in the right direction.
Profile Image for Erwin Rossen.
94 reviews
January 2, 2015
This is a very good book for people who want to start using Test Driven Development using Python. It starts off slowly and explains a bit of theory of testing in general, but luckily focuses more on *how* to do it using Python. It covers all useful topics: doctest, unittest, mock, and nose, and even some more advanced topics like integration with version control systems. It is useful if you have some Python experience, but testing experience with it is not required. The whole purpose of the book is to introduce you to it! There are two types of examples in the book: very simple ones to illustrate a single point, and elaborate ones to see how everything is combined in real life problems. In the first few chapters, I missed some more real life examples, but they turned out to come in later chapters, so hold on! It would have been nice if there were some exercises with associated answers (in the book or online). The book can be purchased cheaply as an e-book here: http://bit.ly/1HKQaIj.
Profile Image for Anton Antonov.
356 reviews51 followers
November 25, 2015
An ok-ish introduction to unit testing with Python.

I would argue with the author's choice to spend so much time on doctest, which I believe, is the least used testing framework. I would've recommended pytest as the starting framework of choice, since it has the least boilerplate, easier to explain and it's actually widely used in popular Python projects.

I loved that the author dedicated a chapter to nose since it's compatible with other testing frameworks and it has a wide . Also it would've been awesome if there was a chapter for BDD too.

But in the end, the book lacks good testing scenarios. It could've been better than Python Testing Cookbook, but for now the later remains a better testing introductory and cookbook.
230 reviews3 followers
December 3, 2015
Very, very brief coverage on the topic of Python testing. I found the examples inconsistent and close to useless.
Displaying 1 - 7 of 7 reviews

Can't find what you're looking for?

Get help and learn more about the design.