core-tests#
A reusable library that provides CLI commands for running unittest-based
tests and generating code coverage reports. Consuming projects wire cli_tests
into their own CommandCollection to expose run-tests and run-coverage
without duplicating that logic, keeping the ecosystem DRY.
This library is intentionally scoped to unittest and coverage.
If your project requires pytest-specific features, install pytest directly
or via core-dev-tools and invoke it standalone.
Documentation Contents#
Features#
Unittest abstraction: Expose
run-testsandrun-coveragein any project without duplicating boilerplate.Flexible Test Discovery: Default pattern
tests_*.pytriggers discovery across all three built-in patterns:test_*.py,*_test.py,tests_*.py.Custom Pattern Support: Override discovery with
--patternto target a specific file naming convention.Test Organization: Target specific directories (unit, integration, functional, etc.) via
--test-type.Branch Coverage Reports: Generate branch-level coverage reports and optional HTML output.
CLI Integration: Easy integration via Click command collections.
Installation#
Install the package:
pip install core-tests
uv pip install core-tests # Or using UV...
pip install -e ".[dev]" # For development...
How to Use#
Create a manager.py file in your project root to integrate
the test commands:
from click.core import CommandCollection
from core_tests.tests.runner import cli_tests
if __name__ == "__main__":
cli = CommandCollection(sources=[cli_tests()])
cli()
Run your tests:
python manager.py run-tests
python manager.py run-coverage
Contributing#
Contributions are welcome! Please:
Fork the repository.
Create a feature branch.
Write tests for new functionality.
Ensure all tests pass:
python manager.py run-tests.Run linting:
pylint core_tests.Run security checks:
bandit -r core_tests.Submit a pull request.
License#
This project is licensed under the MIT License. See the LICENSE file for details.
Links#
Documentation: https://core-tests.readthedocs.io/en/latest/
Repository: bytecode-solutions/core/core-tests
Changelog: bytecode-solutions/core/core-tests/-/blob/master/CHANGELOG.md
Support#
For questions or support, please open an issue on GitLab or contact the maintainers.