1{ lib
2, buildPythonPackage
3, fetchFromGitHub
4, ansible-core
5, coreutils
6, coverage
7, pytest
8, pytestCheckHook
9, pythonOlder
10}:
11
12buildPythonPackage rec {
13 pname = "pytest-ansible";
14 version = "3.1.5";
15 format = "pyproject";
16
17 disabled = pythonOlder "3.9";
18
19 src = fetchFromGitHub {
20 owner = "ansible";
21 repo = pname;
22 rev = "refs/tags/v${version}";
23 hash = "sha256-stsgVJseZ02C7nG0Hm0wfAnhoLpM3qRZ2Lkr1N5hODw=";
24 };
25
26 postPatch = ''
27 substituteInPlace tests/conftest.py inventory \
28 --replace '/usr/bin/env' '${coreutils}/bin/env'
29 '';
30
31 buildInputs = [
32 pytest
33 ];
34
35 propagatedBuildInputs = [
36 ansible-core
37 ];
38
39 nativeCheckInputs = [
40 coverage
41 pytestCheckHook
42 ];
43
44 preCheck = ''
45 export HOME=$TMPDIR
46 '';
47
48 pytestFlagsArray = [
49 "tests/"
50 ];
51
52 disabledTests = [
53 # Host unreachable in the inventory
54 "test_become"
55 # [Errno -3] Temporary failure in name resolution
56 "test_connection_failure_v2"
57 "test_connection_failure_extra_inventory_v2"
58 ];
59
60 pythonImportsCheck = [
61 "pytest_ansible"
62 ];
63
64 meta = with lib; {
65 description = "Plugin for py.test to simplify calling ansible modules from tests or fixtures";
66 homepage = "https://github.com/jlaska/pytest-ansible";
67 changelog = "https://github.com/ansible-community/pytest-ansible/releases/tag/v${version}";
68 license = licenses.mit;
69 maintainers = with maintainers; [ costrouc ];
70 };
71}