O'Reilly logo

Mastering Python by Rick van Hattem

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required