Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python3Packages.pytest-cov-stub: init at 1.0.0 #328550

Merged
merged 4 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkgs/applications/office/todoman/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ python3.pkgs.buildPythonApplication rec {
hypothesis
pytestCheckHook
glibcLocales
pytest-cov
pytest-cov-stub
];

LC_ALL = "en_US.UTF-8";
Expand Down
22 changes: 22 additions & 0 deletions pkgs/development/python-modules/pytest-cov-stub/default.nix
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 pkgs/development/python-modules/pytest-cov-stub/src/pyproject.toml
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"
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
9 changes: 2 additions & 7 deletions pkgs/development/python-modules/strct/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
buildPythonPackage,
setuptools,
pytestCheckHook,
pytest-cov-stub,
sortedcontainers,
}:

Expand All @@ -19,20 +20,14 @@ buildPythonPackage rec {
hash = "sha256-uPM2U+emZUCGqEhIeTBmaOu8eSfK4arqvv9bItBWpUs=";
};

postPatch = ''
substituteInPlace pyproject.toml \
--replace-fail \
'"--cov' \
'#"--cov'
'';

# don't append .dev0 to version
env.RELEASING_PROCESS = "1";

nativeBuildInputs = [ setuptools ];

nativeCheckInputs = [
pytestCheckHook
pytest-cov-stub
sortedcontainers
];

Expand Down
7 changes: 2 additions & 5 deletions pkgs/tools/misc/remote-exec/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
, toml
, watchdog
, pytestCheckHook
, pytest-cov-stub
, rsync
}:

Expand Down Expand Up @@ -44,11 +45,6 @@ buildPythonApplication rec {
watchdog
];

# disable pytest --cov
preCheck = ''
rm setup.cfg
'';

doCheck = true;

nativeCheckInputs = [
Expand All @@ -57,6 +53,7 @@ buildPythonApplication rec {

checkInputs = [
pytestCheckHook
pytest-cov-stub
];

disabledTestPaths = lib.optionals stdenv.isDarwin [
Expand Down
2 changes: 2 additions & 0 deletions pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12343,6 +12343,8 @@ self: super: with self; {

pytest-cov = callPackage ../development/python-modules/pytest-cov { };

pytest-cov-stub = callPackage ../development/python-modules/pytest-cov-stub { };

pytest-cram = callPackage ../development/python-modules/pytest-cram { };

pytest-datadir = callPackage ../development/python-modules/pytest-datadir { };
Expand Down