1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 isPy312,
6 fetchFromGitHub,
7 flaky,
8 hypothesis,
9 pytest-xdist,
10 pytestCheckHook,
11 pythonOlder,
12 setuptools,
13 tomli,
14}:
15
16buildPythonPackage rec {
17 pname = "coverage";
18 version = "7.8.2";
19 pyproject = true;
20
21 src = fetchFromGitHub {
22 owner = "nedbat";
23 repo = "coveragepy";
24 tag = version;
25 hash = "sha256-PCMGxyG5zIc8iigi9BsuhyuyQindZnewqTgxErT/jHw=";
26 };
27
28 postPatch = ''
29 # don't write to Nix store
30 substituteInPlace tests/conftest.py \
31 --replace-fail 'if WORKER == "none":' "if False:"
32 '';
33
34 build-system = [ setuptools ];
35
36 optional-dependencies = {
37 toml = lib.optionals (pythonOlder "3.11") [
38 tomli
39 ];
40 };
41
42 nativeCheckInputs = [
43 flaky
44 hypothesis
45 pytest-xdist
46 pytestCheckHook
47 ];
48
49 preCheck = ''
50 export PATH="$PATH:$out/bin"
51 # import from $out
52 rm -r coverage
53 '';
54
55 disabledTests = [
56 "test_all_our_source_files"
57 "test_doctest"
58 "test_files_up_one_level"
59 "test_get_encoded_zip_files"
60 "test_metadata"
61 "test_more_metadata"
62 "test_multi"
63 "test_no_duplicate_packages"
64 "test_xdist_sys_path_nuttiness_is_fixed"
65 "test_zipfile"
66 ]
67 ++ lib.optionals (isPy312 && stdenv.hostPlatform.system == "x86_64-darwin") [
68 # substring that may not be in string is part of the pytest output hash, which appears in the string
69 "test_nothing_specified"
70 "test_omit"
71 "test_omit_2"
72 "test_omit_as_string"
73 ];
74
75 disabledTestPaths = [
76 "tests/test_debug.py"
77 "tests/test_plugins.py"
78 "tests/test_process.py"
79 "tests/test_report.py"
80 "tests/test_venv.py"
81 ];
82
83 meta = {
84 changelog = "https://github.com/nedbat/coveragepy/blob/${src.tag}/CHANGES.rst";
85 description = "Code coverage measurement for Python";
86 homepage = "https://github.com/nedbat/coveragepy";
87 license = lib.licenses.asl20;
88 maintainers = with lib.maintainers; [ dotlambda ];
89 };
90}