Skip to main content

core-tests

A reusable library that provides CLI commands for running unittest-based tests and generating code coverage reports. It wraps Python’s built-in unittest framework and coverage into a Click command group so consuming projects can use python manager.py run-tests and python manager.py run-coverage without duplicating that logic across every project in the ecosystem.

This library is intentionally scoped to unittest and coverage. If your project requires pytest-specific features (fixtures, parametrize, plugins, parallel execution), install pytest directly or via core-dev-tools and invoke it standalone — it is a better fit for that use case than routing it through this abstraction layer.


PyPI Downloads Python Versions License Pipeline Status Docs Status Security

Installation

Install from PyPI using pip:

pip install core-tests
uv pip install core-tests  # Or using UV...

Features

  • Unified CLI abstraction: Expose run-tests and run-coverage in any project without duplicating boilerplate — just wire cli_tests into your CommandCollection.

  • Flexible Test Discovery: Supports multiple file patterns out of the box:

    • test_*.py (standard pattern)

    • *_test.py (alternative pattern)

    • tests_*.py (custom pattern)

  • Custom Pattern Support: Override discovery with --pattern for non-standard file layouts.

  • Enforced Coverage: run-coverage applies the fail_under setting of your coverage configuration, or --fail-under for a single run, and exits non-zero when the total is below it.

  • CI-ready Reports: Writes coverage.xml (Cobertura, relative paths) beside the HTML report, so a CI platform can annotate a merge request diff, and the JUnit XML of the results to .reports/, so it can show a test report instead of console output.

  • Test Organization: Target specific test directories (unit, integration, functional, etc.) via --test-type.

  • Branch Coverage Reports: Generate branch-level coverage reports and optional HTML output.

  • DRY principle: One implementation shared across all projects in the ecosystem.

How to Use

Create a manager.py file in your project root to integrate the test commands:

# manager.py
from click.core import CommandCollection
from core_tests.tests.runner import cli_tests

if __name__ == "__main__":
    cli = CommandCollection(sources=[cli_tests])
    cli()

This setup provides two commands:

  • run-tests: Execute unittest-based test suites

  • run-coverage: Generate code coverage reports

Example usage:

python manager.py run-tests --test-type unit
python manager.py run-coverage

Available Commands

run-tests

Execute unittest-based test suites with flexible options:

Options:

  • --test-type: Folder name under ./tests directory (e.g., unit, integration, functional). Default: unit

  • --pattern: File pattern to match test files (e.g., *.py, test_*.py). Defaults to multi-pattern discovery.

Examples:

# Run unit tests (default)
python manager.py run-tests --test-type unit

# Run integration tests
python manager.py run-tests --test-type integration

# Run tests with a custom file pattern
python manager.py run-tests --test-type functional --pattern "*.py"

# Run tests in a custom folder
python manager.py run-tests --test-type "custom_folder"

run-coverage

Generate code coverage reports across all test directories:

Options:

  • --save-report: Save the reports to disk: the HTML and XML coverage reports, and the JUnit XML of the results in .reports/. Default: True

  • --fail-under: Minimum total coverage percentage. Exits non-zero below it, and takes precedence over the fail_under setting of the coverage configuration. Default: unset, so the configured value applies.

Examples:

python manager.py run-coverage
python manager.py run-coverage --save-report false
python manager.py run-coverage --fail-under 90

The HTML report lands in htmlcov/, and a Cobertura coverage.xml beside it, with paths relative to the working directory so a CI platform can map them onto the repository.

Quick Start

Setting Up Environment

  1. Install required libraries:

pip install --upgrade pip
pip install virtualenv
  1. Create Python virtual environment:

virtualenv --python=python3.12 .venv
  1. Activate the virtual environment:

source .venv/bin/activate
  1. Install the package:

pip install -e ".[dev]"

Tests and Coverage

python manager.py run-tests --test-type unit
python manager.py run-tests --test-type integration
python manager.py run-tests --test-type functional --pattern "*.py"
python manager.py run-coverage

Using pytest directly

unittest cannot discover standalone test_* functions or use pytest fixtures. If your project relies on those features, invoke pytest directly:

pytest tests/unit/
pytest -n auto --cov=your_package --cov-report=html

Install pytest via pip or through core-dev-tools:

pip install pytest pytest-xdist pytest-cov
# or
pip install ".[dev]"  # if core-dev-tools includes pytest

Contributing

Contributions are welcome! Please:

  1. Fork the repository

  2. Create a feature branch

  3. Write tests for new functionality

  4. Ensure all tests pass: python manager.py run-tests --test-type unit

  5. Run linting: pylint core_tests

  6. Run security checks: bandit -r core_tests

  7. Submit a pull request

License

This project is licensed under the MIT License. See the LICENSE file for details.

Support

For questions or support, please open an issue on GitLab or contact the maintainers.

Authors

Metadata

Release files for core-tests 2.3.2

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

Source distribution (sdist)

Source distribution for core-tests 2.3.2
File Size Uploaded Provenance Actions
core_tests-2.3.2.tar.gz 10.6 kB With provenance Details for core_tests-2.3.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for core-tests 2.3.2
File Interpreter ABI Platform Actions
core_tests-2.3.2-py3-none-any.whl Python 3 none any Details for core_tests-2.3.2-py3-none-any.whl

Total release size: 19.3 kB

Release files / core_tests-2.3.2.tar.gz

Download URL core_tests-2.3.2.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4817b0a5651b38d04f99640f58ef3817aa956baa9aae3c3107a96317cc31de05
BLAKE2b-256 checksum
How to use checksums
d0a9922a892f96f703db7d1b0dd8a44df979eae27e16fa9003f60034f2dae946
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.15.2

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 GitLab CI/CD, verified by PyPI on Nov 12, 2026.

Transparency log

Release files / core_tests-2.3.2-py3-none-any.whl

Download URL core_tests-2.3.2-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ccaca7ada428250ade22480a827ad2fecdc8ae0285a0f2e190a8d3f2e1e1cca1
BLAKE2b-256 checksum
How to use checksums
71457a514ce331d57f490b8c176f221e20c7ae30e9e11cbdbe73ef111abd9f4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.15.2

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 GitLab CI/CD, verified by PyPI on Nov 12, 2026.

Transparency log

Security for core-tests 2.3.2

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for core_tests-2.3.2.tar.gz

PyPI Publish Attestation

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

Signed by GitLab CI/CD, verified by PyPI on Nov 12, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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