Skip to main content

cocotest

Lightweight, opinionated test orchestration framework for cocotb.

Quickstart

Cocotest is intended to work in similar fashion to pytest. We do not intend to provide as many features as pytest, far from it, but we take a lot of inspiration from it. Cocotest should feel familiar for developers with experience in the Python ecosystem.

Installation

You can install cocotest using pip or uv:

pip install cocotest

# Or with uv:
uv add cocotest

Getting started

Once cocotest is installed, you can run your tests with the following command:

cocotest /path/to/tests

# Or with uv:
uv run cocotest /path/to/tests

Of course, you need to write your tests in such a way that cocotest knows what to do with them:

from cocotb.handle import HierarchyObject

from cocotest import DUTSpec

dut = DUTSpec(
    simulator="ghdl",
    sources=["testbench/heartbeat/heartbeat.vhd"],
    hdl_toplevel="heartbeat",
    lang="vhdl",
    build_args=["--std=08"],
    test_args=["--std=08"],
)


async def test_heartbeat_pass(dut: HierarchyObject):
    print("Inside test: test_heartbeat_pass")
    pass

Here there are two important things:

  • dut = DUTSpec(...): this is where we tell cocotest about the DUT that we will use, so it knows how to launch cocotb;
  • async def test_heartbeat_pass(dut: HierarchyObject): here we declare a test.

There are 3 conditions for our test to be detected by cocotest:

  • async def: the test function must be asynchronous, as it will be run inside cocotb and manipulate the DUT;
  • test_...: its name must start with "test_" so cocotest knows how to find it;
  • dut: its DUT argument for the cocotb test must have the same name as some DUTSpec instance present in the scope. This way, cocotest will know what cocotb test to launch with which DUT.

And... that's it! Just use the cocotest command and your test will run. No need for fancy makefiles, no need for @cocotb.test; you can now define various DUTs to use in various test cases which will be automatically run by cocotest. :)

Contributing

Before contributing, read CONTRIBUTING.md.

Note: contributions are closed for the moment.

Testing cocotest

Cocotest is made for running cocotb tests, but it must itself be tested so we know it works. For this, we rely on good old pytest.

A word about test dependencies

Most of the tests can be run with the dev dependencies from the uv project. However, some tests will try to spawn a cocotest subprocess. With this cocotest call, they will try to run ghdl. For that reason, you need to install ghdl if you want to be able to run all of the tests.

Running the tests

Once you have all the dependencies installed, you can run the tests using pytest:

pytest tests

# Or with uv:
uv run pytest tests

License

This work is distributed under the MIT license, see the LICENSE file for more information.

Metadata

Release files for cocotest 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cocotest 0.1.0
File Size Uploaded
cocotest-0.1.0.tar.gz 8.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cocotest 0.1.0
File Interpreter ABI Platform
cocotest-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.3 kB

Release files / cocotest-0.1.0.tar.gz

Download URL cocotest-0.1.0.tar.gz
Size 8.5 kB
Tags Source
SHA-256 checksum
How to use checksums
cc6f7f0dbf404b12e81b3cc2e09bcc507af6f0b28ac515cb5925cc81569fcd6f
BLAKE2b-256 checksum
How to use checksums
5c39b9fb623cbde7858162d98d67e668346f94147a868e1bbdcd6512220aa7da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.

Transparency log

Release files / cocotest-0.1.0-py3-none-any.whl

Download URL cocotest-0.1.0-py3-none-any.whl
Size 11.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
06dfb2bd1f41a76451262dba4c032c58b06025a768861fe3378ca0a27418d72d
BLAKE2b-256 checksum
How to use checksums
937be4bc5a9b0ca516a81a772b46fdeb978b29af5d87a079c2ee719937448e02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page