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