-
Book Overview & Buying
-
Table Of Contents
Mastering Python 2E - Second Edition
By :
The py.test tool makes it very easy to write tests and run them. There are a few other options such as nose2 and the bundled unittest module available, but the py.test library offers a very good combination of usability and active development. In the past, I was an avid nose user but have since switched to py.test as it tends to be easier to use and has better community support, in my experience at least. Regardless, nose2 is still a good choice, and if you’re already using either nose or nose2, there is little reason to switch and rewrite all of your tests. When writing tests for a new project, however, py.test can be much more convenient.
Now, we will run the doctests from the previously discussed square.py file using py.test.
First, start by installing py.test, of course:
$ pip3 install pytest pytest-flake8
We also installed pytest-flake8 here because the default pytest.ini for this project depends on it. We will discuss what...