summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/pytest-html/default.nix
blob: 656c14cf3c6ba9a83025b89be7cb82ea31a7afc7 (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
{
  lib,
  buildNpmPackage,
  buildPythonPackage,
  fetchPypi,
  hatch-vcs,
  hatchling,
  jinja2,
  pytest,
  pytest-metadata,
}:
let
  pname = "pytest-html";
  version = "4.1.1";

  src = fetchPypi {
    pname = "pytest_html";
    inherit version;
    hash = "sha256-cKAeiuWAD0oHS1akyxAlyPT5sDi7pf4x48mOuZZobwc=";
  };

  web-assets = buildNpmPackage {
    pname = "${pname}-web-assets";
    inherit version src;

    npmDepsHash = "sha256-aRod+SzVSb4bqEJzthfl/mH+DpbIe+j2+dNtrrhO2xU=";

    installPhase = ''
      runHook preInstall

      install -Dm644 src/pytest_html/resources/{app.js,style.css} -t $out/lib

      runHook postInstall
    '';
  };
in

buildPythonPackage {
  inherit pname version src;
  pyproject = true;

  nativeBuildInputs = [
    hatch-vcs
    hatchling
  ];
  buildInputs = [
    pytest
    web-assets
  ];
  propagatedBuildInputs = [
    jinja2
    pytest-metadata
  ];

  env.HATCH_BUILD_NO_HOOKS = true;

  preBuild = ''
    install -Dm644 ${web-assets}/lib/{app.js,style.css} -t src/pytest_html/resources
  '';

  # tests require network access
  doCheck = false;

  pythonImportsCheck = [ "pytest_html" ];

  meta = {
    description = "Plugin for generating HTML reports";
    homepage = "https://github.com/pytest-dev/pytest-html";
    license = lib.licenses.mpl20;
    maintainers = with lib.maintainers; [ mpoquet ];
  };
}