summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/pytest-notebook/default.nix
blob: 6d24c8c2ac60246ea70491240a07a0f52bac6993 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,

  # build-system
  flit-core,

  # dependencies
  attrs,
  jsonschema,
  nbclient,
  nbdime,
  nbformat,

  # buildInputs
  pytest,

  # tests
  black,
  ipykernel,
  pytest-cov-stub,
  pytest-regressions,
  pytestCheckHook,
  writableTmpDirAsHomeHook,
  pythonAtLeast,
}:

buildPythonPackage rec {
  pname = "pytest-notebook";
  version = "0.10.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "chrisjsewell";
    repo = "pytest-notebook";
    tag = "v${version}";
    hash = "sha256-LoK0wb7rAbVbgyURCbSfckWvJDef3tPY+7V4YU1IBRU=";
  };

  postPatch = ''
    # we disable the tests relying on coverage for unrelated reasons
    substituteInPlace tests/test_execution.py \
      --replace-fail "from coverage import CoverageData" ""
  '';

  build-system = [
    flit-core
  ];

  pythonRelaxDeps = [
    "attrs"
    "nbclient"
  ];

  dependencies = [
    attrs
    jsonschema
    nbclient
    nbdime
    nbformat
  ];

  buildInputs = [ pytest ];

  pythonImportsCheck = [ "pytest_notebook" ];

  nativeCheckInputs = [
    black
    ipykernel
    pytest-cov-stub
    pytest-regressions
    pytestCheckHook
    writableTmpDirAsHomeHook
  ];

  disabledTests = [
    # AssertionError: FILES DIFFER:
    "test_diff_to_string"

    # pytest_notebook.execution.CoverageError: An error occurred while executing coverage start-up
    # TypeError: expected str, bytes or os.PathLike object, not NoneType
    "test_execute_notebook_with_coverage"
    "test_regression_coverage"

    # pytest_notebook.nb_regression.NBRegressionError
    "test_regression_regex_replace_pass"
  ]
  ++ lib.optionals (pythonAtLeast "3.13") [
    # AssertionError: FILES DIFFER:
    "test_documentation"
  ];

  __darwinAllowLocalNetworking = true;

  meta = {
    changelog = "https://github.com/chrisjsewell/pytest-notebook/blob/${src.tag}/docs/source/changelog.md";
    description = "Pytest plugin for regression testing and regenerating Jupyter Notebooks";
    homepage = "https://github.com/chrisjsewell/pytest-notebook";
    license = lib.licenses.bsd3;
    maintainers = with lib.maintainers; [ dotlambda ];
  };
}