1{ lib
2, stdenv
3, ansible-core
4, buildPythonPackage
5, coreutils
6, fetchFromGitHub
7, pytest
8, pytestCheckHook
9, pythonOlder
10, setuptools
11, setuptools-scm
12, wheel
13}:
14
15buildPythonPackage rec {
16 pname = "pytest-ansible";
17 version = "4.1.1";
18 format = "pyproject";
19
20 disabled = pythonOlder "3.9";
21
22 src = fetchFromGitHub {
23 owner = "ansible";
24 repo = "pytest-ansible";
25 rev = "refs/tags/v${version}";
26 hash = "sha256-51DQ+NwD454XaYLuRxriuWRZ8uTSX3ZpadXdxs7FspQ=";
27 };
28
29 postPatch = ''
30 substituteInPlace tests/conftest.py inventory \
31 --replace '/usr/bin/env' '${coreutils}/bin/env'
32 '';
33
34 env.SETUPTOOLS_SCM_PRETEND_VERSION = version;
35
36 nativeBuildInputs = [
37 setuptools
38 setuptools-scm
39 wheel
40 ];
41
42 buildInputs = [
43 pytest
44 ];
45
46 propagatedBuildInputs = [
47 ansible-core
48 ];
49
50 nativeCheckInputs = [
51 pytestCheckHook
52 ];
53
54 preCheck = ''
55 export HOME=$TMPDIR
56 '';
57
58 pytestFlagsArray = [
59 "tests/"
60 ];
61
62 disabledTests = [
63 # Host unreachable in the inventory
64 "test_become"
65 # [Errno -3] Temporary failure in name resolution
66 "test_connection_failure_v2"
67 "test_connection_failure_extra_inventory_v2"
68 ] ++ lib.optionals stdenv.isDarwin [
69 # These tests fail in the Darwin sandbox
70 "test_ansible_facts"
71 "test_func"
72 "test_param_override_with_marker"
73 ];
74
75 disabledTestPaths = [
76 # Test want s to execute pytest in a subprocess
77 "tests/integration/test_molecule.py"
78 ] ++ lib.optionals stdenv.isDarwin [
79 # These tests fail in the Darwin sandbox
80 "tests/test_adhoc.py"
81 "tests/test_adhoc_result.py"
82 ];
83
84 pythonImportsCheck = [
85 "pytest_ansible"
86 ];
87
88 meta = with lib; {
89 description = "Plugin for pytest to simplify calling ansible modules from tests or fixtures";
90 homepage = "https://github.com/jlaska/pytest-ansible";
91 changelog = "https://github.com/ansible-community/pytest-ansible/releases/tag/v${version}";
92 license = licenses.mit;
93 maintainers = with maintainers; [ tjni ];
94 };
95}