cocotb-test
What it is and what it does
cocotb-test is a pytest plugin that bridges cocotb (a Python-based hardware simulation framework) with standard Python unit testing. Instead of writing Makefiles and shell scripts to orchestrate HDL simulations, you write pytest test functions that call cocotb-test's `run()` function with your Verilog or VHDL sources, top-level module name, and cocotb test module. The package handles compilation, simulation, and result collection, letting you use pytest's full ecosystem—parameterization, filtering, parallel execution via pytest-xdist, and reporting plugins.
The package depends on cocotb (the core simulation engine), pytest (the test runner), and find_libpython (a utility for locating Python libraries). It supports Python 3.7 and later. Maintenance is dormant, with no activity for 587 days, though a release occurred on 2025-01-04. Installation requires a working simulator and environment setup, making it a high-friction dependency for teams not already running hardware simulations.
Use it for:
- Run Verilog or VHDL testbenches as pytest tests without writing Makefiles or shell scripts.
- Parameterize HDL simulations using pytest.mark.parametrize to test designs across multiple configurations.
- Parallelize simulation runs across CPU cores using pytest-xdist for faster design verification.
- Integrate hardware verification into CI/CD pipelines alongside software unit tests.
- Generate junitxml or HTML reports from cocotb test results using pytest plugins.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
cocotb-test wraps cocotb hardware simulations in pytest, letting you write and run HDL testbenches as standard Python unit tests without Makefiles.
Yes, if you are already using cocotb and pytest in a hardware design flow and want to eliminate Makefiles and gain pytest's testing ecosystem. No, if you are new to hardware simulation or lack a simulator installed—the high install friction and dormant maintenance make this a specialist tool. Yes-with-conditions: verify compatibility with your cocotb version and simulator before adopting in a new project.
Install
cocotb-test on PyPI
pip
pip install cocotb-testuv
uv add cocotb-testpoetry
poetry add cocotb-testInstalling cocotb-test
Before you install
High install friction: requires cocotb, a simulator (e.g. Icarus Verilog), and find_libpython as runtime dependencies. Maintenance is dormant—last release was 587 days ago, though the package did receive a release on 2025-01-04.
License in practice
BSD permissive license means you can use, modify, and distribute cocotb-test freely in commercial and open-source projects with minimal restrictions.
Quickstart
pip install cocotb-test
from cocotb_test.simulator import run
def test_dff():
run(
verilog_sources=["dff.sv"],
toplevel="dff",
module="dff_cocotb"
)
# Run: SIM=icarus pytest test_dff.py
Requires a simulator (e.g. Icarus Verilog) installed and SIM environment variable set; cocotb must be installed first.
Verify before relying
- Whether the package actively maintains compatibility with current cocotb versions given dormant maintenance status.
- Performance characteristics when running large test suites or using pytest-xdist parallelization.
- Support status for simulators other than Icarus Verilog (e.g. Verilator, commercial tools).
Package facts
| License | BSD (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | high — source build required |
| Runtime dependencies | 3 — cocotb, pytest, find_libpython |
| Maintenance | dormant — 587 days since the last release |
| First released | |
| Downloads | 242,306/month — #8,860 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: cocotb_test-0.2.6.tar.gz
Tags
More Electronic Design Automation (EDA) packages
Parses and elaborates SystemRDL 2.0 register…
permissive · top 15,000 on PyPI
planarityTests whether a graph is planar, computes…
permissive · top 15,000 on PyPI
cocotbcocotb is a Python framework for writing…
permissive · top 15,000 on PyPI
pyslangpyslang provides Python bindings to parse,…
permissive · top 15,000 on PyPI
peakrdl-ipxactConverts between SystemRDL register…
copyleft · top 15,000 on PyPI
klayoutKLayout is a Python package for layout viewing,…
copyleft · top 15,000 on PyPI
cocotb-buscocotb-bus provides pre-built testbenching…
unclear · top 15,000 on PyPI
pyuvmImplements the IEEE 1800.2 Universal…
permissive · top 15,000 on PyPI
cocotb-coverageAdds constrained randomization and functional…
permissive · top 15,000 on PyPI
pyucisPyUCIS provides a Python API and CLI tools for…
permissive · top 15,000 on PyPI
amaranthAmaranth is a Python-based hardware definition…
permissive · top 15,000 on PyPI
pytest-parallelA pytest plugin that runs tests in parallel…
permissive · top 15,000 on PyPI
pytest-replayA pytest plugin that records test execution…
permissive · top 15,000 on PyPI
pytest-cppA pytest plugin that discovers and runs C++…
permissive · top 15,000 on PyPI
pytest-odoopytest-odoo is a pytest plugin that runs Odoo…
agpl · top 15,000 on PyPI