1{
2 lib,
3 buildPythonPackage,
4 fetchPypi,
5 setuptools,
6 setuptools-scm,
7 pytest,
8 jinja2,
9 matplotlib,
10 packaging,
11 pillow,
12 pytestCheckHook,
13}:
14
15buildPythonPackage rec {
16 pname = "pytest-mpl";
17 version = "0.17.0";
18 pyproject = true;
19
20 src = fetchPypi {
21 inherit pname version;
22 hash = "sha256-++8F1+ZktLM0UvtpisGI5SJ5HzJ9405+o329/p1SysY=";
23 };
24
25 build-system = [
26 setuptools
27 setuptools-scm
28 ];
29
30 buildInputs = [ pytest ];
31
32 dependencies = [
33 jinja2
34 matplotlib
35 packaging
36 pillow
37 ];
38
39 nativeCheckInputs = [ pytestCheckHook ];
40
41 disabledTestPaths = [
42 # Following are broken since at least a1548780dbc79d76360580691dc1bb4af4e837f6
43 "tests/subtests/test_subtest.py"
44 ];
45
46 # need to set MPLBACKEND=agg for headless matplotlib for darwin
47 # https://github.com/matplotlib/matplotlib/issues/26292
48 # The default tolerance is too strict in our build environment
49 # https://github.com/matplotlib/pytest-mpl/pull/9
50 # https://github.com/matplotlib/pytest-mpl/issues/225
51 preCheck = ''
52 export MPLBACKEND=agg
53 substituteInPlace pytest_mpl/plugin.py \
54 --replace-fail "DEFAULT_TOLERANCE = 2" "DEFAULT_TOLERANCE = 10"
55 substituteInPlace tests/test_pytest_mpl.py \
56 --replace-fail "DEFAULT_TOLERANCE = 10 if WIN else 2" "DEFAULT_TOLERANCE = 10"
57 '';
58
59 meta = with lib; {
60 description = "Pytest plugin to help with testing figures output from Matplotlib";
61 homepage = "https://github.com/matplotlib/pytest-mpl";
62 license = licenses.bsd3;
63 maintainers = [ ];
64 };
65}