Skip to main content

Unittest runner producing Test Anything Protocol (TAP) output

Project description

simpletap is a test runner that integrates with the unittest framework to produce TAP (Test Anything Protocol) compatible output.


In your test scripts, instead of:

if __name__ == "__main__":


if __name__ == "__main__":
    from simpletap import TAPTestRunner

A small test case like:

import unittest

class IntegerArithmeticTestCase(unittest.TestCase):
    def testAdd(self):  # test method names begin 'test*'
        "test adding values"
        self.assertEqual((1 + 2), 3)
        self.assertEqual(0 + 1, 1)

    def testMultiply(self):
        "test multiplying values"
        self.assertEqual((0 * 10), 0)
        self.assertEqual((5 * 8), 40)

    def testFail(self):
        "a failing test"
        self.assertEqual(0, 1)

    def testExpectFail(self):
        "we saw this coming"
        self.assertEqual(0, 1)

    def testUnexpectFail(self):
        "someone fixed it already"
        self.assertEqual(0, 0)

    @unittest.skipIf(True, "Skipping this one")
    def testSkip(self):
        "pending a fix"
        self.assertEqual(0, 1)

    def testError(self):
        "oops something went wrong"
        no_such_variable + 1  # Oops!

if __name__ == "__main__":
    from simpletap import TAPTestRunner

When saved in a file called and executed would produce:

ok 1 - test adding values
not ok 2 - oops something went wrong
# ERROR: NameError on file line 38 in testError: 'no_such_variable + 1  # Oops!':
#        name 'no_such_variable' is not defined
ok 3 - we saw this coming # TODO
# EXPECTED_FAILURE: AssertionError on file line 24 in testExpectFail: 'self.assertEqual(0, 1)':
#                   0 != 1
not ok 4 - a failing test
# FAIL: AssertionError on file line 19 in testFail: 'self.assertEqual(0, 1)':
#       0 != 1
ok 5 - test multiplying values
ok 6 - pending a fix # skip
#       Skipping this one
not ok 7 - someone fixed it already # FIXED
#                     testUnexpectFail (__main__.IntegerArithmeticTestCase)

You can also launch simpletap directly from the command line in much the same way you do with unittest:

python -m simpletap test.IntegerArithmeticTestCase


The test suite is configured to run via tox.


simpletap is currently being used by:



  • skip keyword is no longer used. Now fully compliant with TAP using ok/not ok

  • SKIP now results in ok

  • EXPECTED_FAILURE now results in ok

  • UNEXPECTED_SUCCESS is now explicitly handled and results in not ok

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simpletap-2.0.0.tar.gz (11.6 kB view hashes)

Uploaded source

Built Distribution

simpletap-2.0.0-py3-none-any.whl (12.6 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page