Testing with py.test
The py.test tool makes it very easy to write tests and run them. There are a few other options such as nose 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, nose is still a good choice, and if you're already using it, 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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access