2023-08-04 22:07:22 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
2020-04-24 23:36:52 +00:00
|
|
|
, buildPythonPackage
|
|
|
|
, fetchFromGitHub
|
2023-05-24 13:37:59 +00:00
|
|
|
, ansible-core
|
|
|
|
, coreutils
|
|
|
|
, coverage
|
2020-04-24 23:36:52 +00:00
|
|
|
, pytest
|
2023-05-24 13:37:59 +00:00
|
|
|
, pytestCheckHook
|
|
|
|
, pythonOlder
|
2023-08-10 07:59:29 +00:00
|
|
|
, setuptools
|
|
|
|
, setuptools-scm
|
|
|
|
, wheel
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "pytest-ansible";
|
2023-08-10 07:59:29 +00:00
|
|
|
version = "3.2.1";
|
2023-05-24 13:37:59 +00:00
|
|
|
format = "pyproject";
|
|
|
|
|
|
|
|
disabled = pythonOlder "3.9";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "ansible";
|
2023-05-24 13:37:59 +00:00
|
|
|
repo = pname;
|
|
|
|
rev = "refs/tags/v${version}";
|
2023-08-10 07:59:29 +00:00
|
|
|
hash = "sha256-fSerRbd7QeEdTfyy2lVLq7FKHWWT0MlutonunHhM5M4=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace tests/conftest.py inventory \
|
|
|
|
--replace '/usr/bin/env' '${coreutils}/bin/env'
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2023-08-10 07:59:29 +00:00
|
|
|
env.SETUPTOOLS_SCM_PRETEND_VERSION = version;
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
setuptools
|
|
|
|
setuptools-scm
|
|
|
|
wheel
|
|
|
|
];
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
buildInputs = [
|
|
|
|
pytest
|
|
|
|
];
|
2021-04-05 15:23:46 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
ansible-core
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
nativeCheckInputs = [
|
|
|
|
coverage
|
|
|
|
pytestCheckHook
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
preCheck = ''
|
|
|
|
export HOME=$TMPDIR
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
pytestFlagsArray = [
|
|
|
|
"tests/"
|
|
|
|
];
|
|
|
|
|
|
|
|
disabledTests = [
|
|
|
|
# Host unreachable in the inventory
|
|
|
|
"test_become"
|
|
|
|
# [Errno -3] Temporary failure in name resolution
|
|
|
|
"test_connection_failure_v2"
|
|
|
|
"test_connection_failure_extra_inventory_v2"
|
2023-08-04 22:07:22 +00:00
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
# These tests fail in the Darwin sandbox
|
|
|
|
"test_ansible_facts"
|
|
|
|
"test_func"
|
|
|
|
"test_param_override_with_marker"
|
|
|
|
];
|
|
|
|
|
|
|
|
disabledTestPaths = lib.optionals stdenv.isDarwin [
|
|
|
|
# These tests fail in the Darwin sandbox
|
|
|
|
"tests/test_adhoc.py"
|
|
|
|
"tests/test_adhoc_result.py"
|
2023-05-24 13:37:59 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
pythonImportsCheck = [
|
|
|
|
"pytest_ansible"
|
|
|
|
];
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Plugin for py.test to simplify calling ansible modules from tests or fixtures";
|
2023-05-24 13:37:59 +00:00
|
|
|
homepage = "https://github.com/jlaska/pytest-ansible";
|
|
|
|
changelog = "https://github.com/ansible-community/pytest-ansible/releases/tag/v${version}";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.mit;
|
2023-08-10 07:59:29 +00:00
|
|
|
maintainers = with maintainers; [ tjni ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|