https://github.com/ozi-project/tap-producer
Test Anything Protocol producer API for Python.
https://github.com/ozi-project/tap-producer
test-anything-protocol testing
Last synced: 10 months ago
JSON representation
Test Anything Protocol producer API for Python.
- Host: GitHub
- URL: https://github.com/ozi-project/tap-producer
- Owner: OZI-Project
- License: apache-2.0
- Created: 2024-07-04T02:01:23.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-06-14T01:03:24.000Z (about 1 year ago)
- Last Synced: 2025-06-14T01:27:40.406Z (about 1 year ago)
- Topics: test-anything-protocol, testing
- Language: Python
- Homepage: https://pypi.org/project/TAP-Producer
- Size: 649 KB
- Stars: 1
- Watchers: 0
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README
- Changelog: CHANGELOG.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
.. OZI
Classifier: License-Expression :: Apache-2.0 WITH LLVM-exception
Classifier: License-File :: LICENSE.txt
..
Part of TAP-Producer.
See LICENSE.txt in the project root for details.
============
TAP-Producer
============
Producer for Test Anything Protocol output in Python.
.. code-block::
from tap_producer import TAP
with TAP() as t:
t.ok('passed')
t.ok('also passed')
The TAP class automatically counts test points at call time for TAP version 12, 13, and 14.
.. code-block::
from tap_producer import TAP
@TAP(plan=1, version=14)
def f() -> None:
TAP.ok('reason')
f()
TAP can also be used as a function decorator.
.. code-block::
from tap_producer import TAP
TAP.version(14)
TAP.ok('passed')
TAP.end()
The TAP class can also be used as a purely functional API. Normally TAP calls ``end()`` on its own.
.. code-block::
from tap_producer import TAP
with TAP() as t:
t.ok('passed').comment('debug information')
if FAIL_CONDITION:
t.not_ok('did not pass')
t.bail_out()
TAP using version 12 supports plan, ok, not ok, diagnostic comment, and bail out
functionality.
.. code-block::
with TAP(version=13).subtest('subtest') as st:
st.plan(count=1, skip_count=0).ok('ok', {'yaml-key': 'yaml-val'})
TAP version 13 supports the aforementioned as well as subtest context manager
and YAML diagnostic output.
.. code-block::
from tap_producer import TAP
with TAP() as t:
with t.suppress():
t.ok('passed but suppressed')
with t.strict()
t.not_ok('this is now a Python exception')
TAP-Producer also includes two decorators, a suppress context manager for
suppressing TAP output and a strict context manager for raising not ok test
cases to Python errors.
License
-------
Licensed Apache-2.0 WITH LLVM-exception, no NOTICE file needed if you want
to vendor TAP-Producer into your project, see LICENSE.txt for more information.
.. image:: https://raw.githubusercontent.com/sigstore/community/main/artwork/badge/sigstore_codesigned_purple.png
:align: right
:height: 140
:target: https://www.sigstore.dev/