Registry /
testing / coverage-conditional-plugin
Install & Compatibility
Where this runs
tested against v0.9.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.915 runs
installs and imports cleanly · install 0.0s · import 0.000s · 20MB
glibcpy 3.10–3.915 runs
installs and imports cleanly · install 2.3s · import 0.000s · 21MB
18MB installed
● package 18MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
get_env_info
✓ from coverage_conditional_plugin.plugin import get_env_info
This function allows programmatic inspection of the plugin's environment and rules, primarily for debugging or advanced integration, not for standard configuration.
To use the plugin, you must configure it within your `coverage.py` settings, typically in `pyproject.toml` or `.coveragerc`. Define `rules` as Python expressions that determine when lines or blocks of code should be omitted from coverage reports. These rules can reference `os.getenv`, `sys.version_info`, and other global Python context variables.
import os
import sys
from coverage_conditional_plugin.plugin import get_env_info
# --- Example of programmatic usage (less common, for debugging) ---
print("\n--- Plugin Environment Info ---")
print(get_env_info())
print("--------------------------------\n")
# --- Typical usage: configure via pyproject.toml or .coveragerc ---
# Create a `pyproject.toml` file in your project root with this content:
#
# [tool.coverage.run]
# plugins = ["coverage_conditional_plugin"]
#
# [tool.coverage.coverage_conditional_plugin]
# # Example rule 1: omit lines if Python version is below 3.8
# rules = [
# "if sys.version_info < (3, 8): omit",
# # Example rule 2: omit lines starting with 'def debug_feature' if env var is 'true'
# "if os.getenv('SKIP_DEBUG_FEATURES', 'false') == 'true': exclude_lines_starting_with('def debug_feature')",
# ]
#
# Create a dummy Python file (e.g., `my_app.py`) to demonstrate:
# def standard_feature():
# print("This is always covered.")
#
# def debug_feature():
# print("This is a debug-only function.") # Will be excluded if SKIP_DEBUG_FEATURES is 'true'
#
# if sys.version_info >= (3, 8):
# print("Running on Python 3.8 or newer.") # This line would be omitted if Python < 3.8
# else:
# print("Running on Python older than 3.8.")
#
# standard_feature()
# debug_feature()
# --- To run this example from your terminal ---
# 1. Make sure you have `pyproject.toml` and `my_app.py` in your current directory.
# 2. Run coverage normally (all lines covered, assuming Python >= 3.8):
# $ coverage run my_app.py
# $ coverage report -m
#
# 3. Run coverage with an environment variable rule activated:
# $ SKIP_DEBUG_FEATURES=true coverage run my_app.py
# $ coverage report -m
# (Expected: `debug_feature` lines are now marked as omitted/excluded)
# Note: The Python code in this block is for demonstration and `get_env_info()` execution.
# The primary interaction is via `coverage.py` configuration and shell commands.
Upgrade
Version history
0.9.0latest on PyPI · released Jun 2, 2023
Audit
Dependencies
coveragerequiredThis plugin extends Coverage.py and is strictly dependent on it. Version 7.x is officially supported with plugin version >= 0.8.0.
packagingrequiredUsed internally for version parsing and compatibility checks (added in 0.3.1).