Skip to main content

Simple `coverage` Exclusions

Project description

Simple coverage Exclusions

This is a simple plugin for Coverage.py. When you enable it, for example in pyproject.toml:

[tool.coverage.run]
plugins = ["coverage_simple_excludes"]

Then, in addition to the default # pragma: no cover, you get several more comments in the format # cover-... that you can use to specify that lines or blocks of code should be excluded from coverage:

  • # cover-req-ltX.Y and # cover-req-geX.Y, where:
    • X and Y are the major and minor Python version, respectively
    • lt means "a Python version lower than X.Y is required for this line or block of code to be executed and included in the coverage check"
    • ge means "a Python version equal to or higher than X.Y is required"
  • # cover-not-Z and # cover-only-Z, where:
    • not means "this code is not executed on this os/platform/implementation"
    • only means "this code is only executed on this os/platform/implementation"
    • Z may be any of the following values:

Note the comments are case-sensitive. Any amount of whitespace is allowed between the # and cover, including no space.

Examples

if sys.platform != 'win32':  # cover-not-win32
    print("This code is only executed on non-win32 systems")
else:  # cover-only-win32
    print("This code is only executed on win32 systems")

if sys.hexversion < 0x03_0C:  # cover-req-lt3.12
    print("This code is only executed on a version of Python before 3.12")
else:  # cover-req-ge3.12
    print("This code is only executed on Python 3.12 or later")

Author, Copyright, and License

Copyright (c) 2024 Hauke Dämpfling (haukex@zero-g.net) at the Leibniz Institute of Freshwater Ecology and Inland Fisheries (IGB), Berlin, Germany, https://www.igb-berlin.de/

This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see https://www.gnu.org/licenses/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

coverage_simple_excludes-0.9.1.tar.gz (10.4 kB view details)

Uploaded Source

File details

Details for the file coverage_simple_excludes-0.9.1.tar.gz.

File metadata

File hashes

Hashes for coverage_simple_excludes-0.9.1.tar.gz
Algorithm Hash digest
SHA256 7d6e45dc3b2f69e0dfac465354e19dcf8f2475e2e4bccf61aad3c37a38585a4b
MD5 9048f55363f9c6ff1143b3c42b89ac61
BLAKE2b-256 a72c0907e58aa6686efb30b5e3b96ce425f16a0130fefd28f329eb7cd9f5b49a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page