Registry / testing / cocotb-test

cocotb-test

JSON →
library0.2.6pypypi✓ verified 89d ago

cocotb-test is a pytest plugin for running and testing hardware designs with cocotb. It simplifies integration of cocotb tests into Python's pytest framework. Current version is 0.2.6, released 2023-08-22. Release cadence is irregular.

pip install cocotb-test
INSTALL
IMPORT
SIG · COCOTB-TEST
C
cocotb-test
testingpythonv0.2.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cocotb_test
✓ import cocotb_test
Plugin is auto-discovered by pytest; direct import of cocotb_test module is not needed for basic usage.

Basic cocotb test example. Run with: pytest tests/ -v

import cocotb from cocotb.clock import Clock from cocotb.triggers import RisingEdge @cocotb.test() async def test_basic(dut): clock = Clock(dut.clk, 10, units='us') cocotb.start_soon(clock.start()) dut.rst.value = 1 await RisingEdge(dut.clk) dut.rst.value = 0 await RisingEdge(dut.clk) assert dut.q.value == 0
Debug
Known issues
gotchacocotb-test requires a hardware simulator (e.g., Icarus Verilog, Verilator, GHDL) installed and on PATH. If tests hang or fail with 'simulator not found', check your simulation tool installation.
fix
Install a supported simulator and ensure it is in your PATH. For example, on Ubuntu: sudo apt install iverilog
affects: all
deprecatedVersion 0.2.6 does not support pytest 8.0+ properly due to internal changes in pytest's plugin discovery. If you see errors like 'Unknown hook: pytest_configure', pin pytest to <8.0.
fix
Pin pytest<8.0 in your requirements: pytest<8.0
affects: <=0.2.6
gotchaThe module 'cocotb_test' is not intended to be imported directly. Some tutorials import it but that is not required; the plugin is automatically discovered by pytest when installed.
fix
Simply install cocotb-test and run 'pytest' in your test directory; no import needed.
affects: all
Errors
Common errors & fixes
ImportError: cannot import name 'cocotb_test' from 'cocotb_test'
Direct import of 'cocotb_test' module is not necessary and may fail if the module path is not correct.
fix
Remove the import statement; the plugin is auto-discovered by pytest.
pytest: error: unrecognized arguments: --cocotb
Running pytest without having cocotb-test installed, or using an old version of pytest that conflicts.
fix
Ensure cocotb-test is installed (pip install cocotb-test) and use a supported pytest version (<8.0).
OSError: [Simulator] not found
The required HDL simulator (e.g., iverilog) is not installed or not in PATH.
fix
Install the simulator (e.g., 'sudo apt install iverilog' on Ubuntu) and ensure it's in your PATH.
Upgrade
Version history
0.2.6latest on PyPI · released Jan 4, 2025
Audit
Dependencies
cocotbrequiredCore simulation framework
pytestrequiredTest runner
simulatoroptionalHDL simulator (e.g., iverilog, ghdl, verilator) must be installed separately
Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources

No resource links recorded.

cocotb-test — pip install cocotb-test · libregistry