Appendix B. Working with Older Python Versions
This book has been written for Python 3.4. The version of unittest
that comes with the Python 2.x standard library is an older version that doesn't support all the features that we discussed in this book. Additionally, the mock
library was only made a part of the standard library from Python 3.3 onward.
Fortunately, all the features present in the newer versions of Python have been backported under the unittest2
library. We can install this version from PyPi with the following command:
pip install unittest2
Once installed, we have to use the unittest2
library in all references like the following:
import unittest2 class StockTest(unittest2.TestCase): ...
With these changes, we will be able to use all the ...
Get Test-Driven Python Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.