-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #328550 from pbsds/init-pytest-coverage-shim-17214…
…28630 python3Packages.pytest-cov-stub: init at 1.0.0
- Loading branch information
Showing
8 changed files
with
135 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
pkgs/development/python-modules/pytest-cov-stub/default.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
lib, | ||
buildPythonPackage, | ||
python, | ||
hatchling, | ||
}: | ||
|
||
buildPythonPackage rec { | ||
pname = "pytest-cov-stub"; | ||
version = (lib.importTOML ./src/pyproject.toml).project.version; | ||
pyproject = true; | ||
|
||
src = ./src; | ||
|
||
build-system = [ hatchling ]; | ||
|
||
meta = with lib; { | ||
description = "Nixpkgs checkPhase stub for pytest-cov"; | ||
license = licenses.mit; | ||
maintainers = [ lib.maintainers.pbsds ]; | ||
}; | ||
} |
13 changes: 13 additions & 0 deletions
13
pkgs/development/python-modules/pytest-cov-stub/src/pyproject.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[build-system] | ||
requires = ["hatchling"] | ||
build-backend = "hatchling.build" | ||
|
||
[project] | ||
name = "pytest-cov-nixpkgs-stub" | ||
version = "1.0.0" | ||
|
||
[tool.hatch.build.targets.wheel] | ||
packages = ["pytest_cov"] | ||
|
||
[project.entry-points.pytest11] | ||
pytest_cov = "pytest_cov.plugin" |
Empty file.
93 changes: 93 additions & 0 deletions
93
pkgs/development/python-modules/pytest-cov-stub/src/pytest_cov/plugin.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import argparse | ||
import pytest | ||
|
||
class CoverageError(Exception): | ||
pass | ||
|
||
class PytestCovWarning(pytest.PytestWarning): | ||
pass | ||
|
||
class CovDisabledWarning(PytestCovWarning): | ||
pass | ||
|
||
class CovReportWarning(PytestCovWarning): | ||
pass | ||
|
||
class StoreReport(argparse.Action): | ||
def __call__(self, parser, namespace, values, option_string=None): | ||
report_type, file = values | ||
namespace.cov_report[report_type] = file | ||
|
||
def pytest_addoption(parser): | ||
group = parser.getgroup('cov', 'coverage reporting') | ||
group.addoption( | ||
'--cov', | ||
action='append', | ||
default=[], | ||
metavar='SOURCE', | ||
nargs='?', | ||
const=True, | ||
dest='cov_source', | ||
) | ||
group.addoption( | ||
'--cov-reset', | ||
action='store_const', | ||
const=[], | ||
dest='cov_source', | ||
) | ||
group.addoption( | ||
'--cov-report', | ||
action=StoreReport, | ||
default={}, | ||
metavar='TYPE', | ||
type=lambda x: x.split(":", 1) if ":" in x else (x, None), | ||
) | ||
group.addoption( | ||
'--cov-config', | ||
action='store', | ||
default='.coveragerc', | ||
metavar='PATH', | ||
) | ||
group.addoption( | ||
'--no-cov-on-fail', | ||
action='store_true', | ||
default=False, | ||
) | ||
group.addoption( | ||
'--no-cov', | ||
action='store_true', | ||
default=False, | ||
) | ||
group.addoption( | ||
'--cov-fail-under', | ||
action='store', | ||
metavar='MIN', | ||
type=str, | ||
) | ||
group.addoption( | ||
'--cov-append', | ||
action='store_true', | ||
default=False, | ||
) | ||
group.addoption( | ||
'--cov-branch', | ||
action='store_true', | ||
default=None, | ||
) | ||
group.addoption( | ||
'--cov-context', | ||
action='store', | ||
metavar='CONTEXT', | ||
type=str, | ||
) | ||
|
||
def pytest_configure(config): | ||
config.addinivalue_line('markers', 'no_cover: disable coverage for this test.') | ||
|
||
@pytest.fixture | ||
def no_cover(): | ||
pass | ||
|
||
@pytest.fixture | ||
def cov(): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters