Testing
In Chapter 10, Testing and Logging – Preparing for Bugs, we saw a few of the many testing systems for Python. As you might suspect, at least some of these have setup.py
integration. It should be noted that setuptools
even has a dedicated test
command (at the time of writing), but this command has been deprecated and the setuptools
documentation now recommends using tox
. While I am a huge fan of tox
, for immediate local development it often incurs quite a bit of overhead. I find that executing py.test
directly is faster, because you can really quickly test only the bits of the code that you changed.
unittest
Before we start, we should create a test script for our package. For actual tests please look at Chapter 10; in this case, we will just use a no-op test, test.py
:
import unittest
class Test(unittest.TestCase):
def test(self):
pass
The standard python setup.py test
command has been deprecated, so we will run unittest
directly:
$ python3...