This project uses pytest and testcontainers for integration testing, along with coverage.py to track test coverage — including subprocesses.
Install test dependencies:
pip install -r requirements-dev.txtRun all tests (including those that spin up a Kafka container):
pytestYou can run the integration test that uses testcontainers with Kafka:
pytest tests/test_kafka_integration.pyTo enable coverage tracking for both main tests and subprocesses:
export COVERAGE_PROCESS_START=$(pwd)/.coveragercpytest --cov --cov-report=term-missingcoverage html
xdg-open htmlcov/index.html # or open htmlcov/index.html manuallyTo properly collect coverage from subprocesses (like subprocess.run(["python", "consumer.py"])):
- Add this to the top of any script (like
producer.py,consumer.py):
import os
if os.getenv("COVERAGE_PROCESS_START"):
import coverage
coverage.process_startup()