Testing packages

In Chapter 10, Testing and Logging – Preparing for Bugs, the testing chapter, we saw a few of the many testing systems for Python. As you might suspect, at least some of these have setup.py integration.

Unittest

Before we start, we should create a test script for our package. For actual tests, look at Chapter 10, Testing and Logging – Preparing for Bugs, the testing chapter. 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 will run the regular unittest command:

# python setup.py -v test
running test
running "unittest --verbose"
running egg_info
writing Our_little_project.egg-info/PKG-INFO
writing dependency_links to Our_little_project.egg-info/dependency_links.txt ...

Get Python: Journey from Novice to Expert 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.