SimpleTAP
simpletap is a test runner that integrates with the unittest framework to produce TAP (Test Anything Protocol) compatible output.
Usage
In your test scripts, instead of:
if __name__ == "__main__":
unittest.main()
use:
if __name__ == "__main__":
from simpletap import TAPTestRunner
unittest.main(testRunner=TAPTestRunner(buffer=True))
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)
@unittest.expectedFailure
def testExpectFail(self):
"we saw this coming"
self.assertEqual(0, 1)
@unittest.expectedFailure
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
unittest.main(testRunner=TAPTestRunner(buffer=True))
When saved in a file called test.py and executed would produce:
1..7
ok 1 - test.py: test adding values
not ok 2 - test.py: oops something went wrong
# ERROR: NameError on file test.py line 38 in testError: 'no_such_variable + 1 # Oops!':
# name 'no_such_variable' is not defined
ok 3 - test.py: we saw this coming # TODO
# EXPECTED_FAILURE: AssertionError on file test.py line 24 in testExpectFail: 'self.assertEqual(0, 1)':
# 0 != 1
not ok 4 - test.py: a failing test
# FAIL: AssertionError on file test.py line 19 in testFail: 'self.assertEqual(0, 1)':
# 0 != 1
ok 5 - test.py: test multiplying values
ok 6 - test.py: pending a fix # skip
# SKIP:
# Skipping this one
not ok 7 - test.py: someone fixed it already # FIXED
# UNEXPECTED_SUCCESS:
# 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
Testing
The test suite is configured to run via tox.
Projects
simpletap is currently being used by:
Changelog
2.0.0
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
Metadata
Release files for simpletap 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| simpletap-2.0.0.tar.gz | 11.6 kB | Without provenance | Details for simpletap-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| simpletap-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for simpletap-2.0.0-py3-none-any.whl |
Total release size: 24.2 kB
Release files / simpletap-2.0.0.tar.gz
| Download URL | simpletap-2.0.0.tar.gz |
|---|---|
| Size | 11.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d8e12a5783d097ab0e5f394391647a20fface8aace61e2fe28e96a941e52f391
|
|
BLAKE2b-256 checksum How to use checksums |
448060f008ab565d111923928b208dc319207be3d77a7cceb1d10f40f925ec20
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1.post20210325 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.8
|
Release files / simpletap-2.0.0-py3-none-any.whl
| Download URL | simpletap-2.0.0-py3-none-any.whl |
|---|---|
| Size | 12.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b38fa0564678146db147b772edef0984cf3e960c7032049c3198d4fe886d016b
|
|
BLAKE2b-256 checksum How to use checksums |
0358ae45c10d17eb462309a958a02ede7dcf03918a52369845b08f37a12eebf6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1.post20210325 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.8
|
Security for simpletap 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.