Python interface to coveralls.io API for uploading code coverage results
npx @tessl/cli install tessl/pypi-python-coveralls@2.9.0A Python interface to the coveralls.io API for uploading code coverage results from Python projects. The library handles authentication, processes coverage data files, extracts git repository information, and uploads formatted coverage reports to coveralls.io with support for various coverage tools and CI services.
pip install python-coverallsimport coverallsFor programmatic usage:
from coveralls import api, control, repository
from coveralls.control import coveralls
from coveralls.api import post, build_file
from coveralls.repository import repoThe simplest way to upload coverage results after running your test suite:
# Run your tests with coverage
python -m pytest --cov=mypackage
# Upload to coveralls.io
coverallsimport coveralls
# Upload coverage using the main workflow function
exit_code = coveralls.wear()
# Or with custom arguments
args = coveralls.parse_args()
args.base_dir = '/path/to/project'
args.repo_token = 'your_repo_token'
exit_code = coveralls.wear(args)The package is organized into distinct functional modules:
coveralls): Entry point with command-line interface and main workflow coordinationcoveralls.control): Coverage data processing and integration with coverage.pycoveralls.report): Coverage report generation in coveralls.io formatcoveralls.api): HTTP communication with coveralls.io APIcoveralls.repository): Git and Mercurial repository information extractionPrimary entry point providing command-line interface and orchestrating the complete coverage upload workflow from data collection to API submission.
def wear(args=None): ...
def parse_args(): ...Extended coverage functionality that integrates with coverage.py to generate coveralls-specific reports with line-by-line coverage data and source file information.
class coveralls(Coverage):
def coveralls(base_dir, ignore_errors=False, merge_file=None): ...
class CoverallsReporter(Reporter):
def report(base_dir, ignore_errors=False, merge_file=None): ...HTTP interface for communicating with the coveralls.io API, handling authentication, request formatting, and response processing.
def post(url, repo_token, service_job_id, service_name, git, source_files, parallel, skip_ssl_verify=False): ...
def build_file(repo_token, service_job_id, service_name, git, source_files, parallel): ...Version control system integration for extracting git and mercurial repository information including commit details, branch information, and remote URLs.
def repo(root): ...
def gitrepo(root): ...
def hgrepo(root): ...# Authentication
COVERALLS_REPO_TOKEN: str # Repository token for authentication
# CI Service Integration
COVERALLS_SERVICE_NAME: str # CI service name (default: 'travis-ci')
COVERALLS_PARALLEL: bool # Enable parallel builds
TRAVIS_JOB_ID: str # Travis CI job identifier
TRAVIS_BRANCH: str # Git branch from Travis CI
CIRCLE_BRANCH: str # Git branch from Circle CIThe package supports YAML configuration files and coverage.py configuration:
# .coveralls.yml
repo_token: "your_repo_token"
service_name: "travis-ci"
parallel: trueclass Arguments:
"""Parsed command-line arguments and configuration."""
coveralls_url: str
base_dir: str
data_file: str | None
config_file: str | None
coveralls_yaml: str
ignore_errors: bool
merge_file: str | None
nogit: bool
skip_ssl_verify: bool
repo_token: str
service_name: str
service_job_id: str
parallel: bool
class GitInfo:
"""Git repository information."""
head: dict[str, str] # commit info (id, author_name, author_email, etc.)
branch: str
remotes: list[dict[str, str]] # remote info (name, url)
class SourceFile:
"""Coverage information for a single source file."""
name: str # relative file path
source: str # file content
coverage: list[int | None] # line-by-line coverage (None=non-executable, 0=missed, 1=hit)