Unverified Commit 74e1c512 authored by Fabian Affolter's avatar Fabian Affolter Committed by GitHub
Browse files

Merge pull request #228427 from Et7f3/fix_pytest-ansible

python3Packages.pytest-ansible: 2.2.4 -> 3.0.0
parents b04b3345 04635513
Loading
Loading
Loading
Loading
+46 −21
Original line number Diff line number Diff line
{ lib
, buildPythonPackage
, fetchFromGitHub
, ansible
, ansible-core
, coreutils
, coverage
, pytest
, mock
, pytestCheckHook
, pythonOlder
}:

buildPythonPackage rec {
  pname = "pytest-ansible";
  version = "2.2.4";
  version = "3.0.0";
  format = "pyproject";

  disabled = pythonOlder "3.9";

  src = fetchFromGitHub {
    owner = "ansible";
    repo = "pytest-ansible";
    rev = "v${version}";
    sha256 = "0vr015msciwzz20zplxalfmfx5hbg8rkf8vwjdg3z12fba8z8ks4";
    repo = pname;
    rev = "refs/tags/v${version}";
    hash = "sha256-kxOp7ScpIIzEbM4VQa+3ByHzkPS8pzdYq82rggF9Fpk=";
  };

  patchPhase = ''
    sed -i "s/'setuptools-markdown'//g" setup.py
  postPatch = ''
    substituteInPlace tests/conftest.py inventory \
      --replace '/usr/bin/env' '${coreutils}/bin/env'
  '';

  buildInputs = [ pytest ];
  buildInputs = [
    pytest
  ];

  # requires pandoc < 2.0
  # buildInputs = [ setuptools-markdown ];
  nativeCheckInputs =  [ mock ];
  propagatedBuildInputs = [ ansible ];
  propagatedBuildInputs = [
    ansible-core
  ];

  # tests not included with release, even on github
  doCheck = false;
  nativeCheckInputs = [
    coverage
    pytestCheckHook
  ];

  checkPhase = ''
    HOME=$TMPDIR pytest tests/
  preCheck = ''
    export HOME=$TMPDIR
  '';

  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"
  ];

  pythonImportsCheck = [
    "pytest_ansible"
  ];

  meta = with lib; {
    homepage = "https://github.com/jlaska/pytest-ansible";
    description = "Plugin for py.test to simplify calling ansible modules from tests or fixtures";
    homepage = "https://github.com/jlaska/pytest-ansible";
    changelog = "https://github.com/ansible-community/pytest-ansible/releases/tag/v${version}";
    license = licenses.mit;
    maintainers = [ maintainers.costrouc ];
    # https://github.com/ansible-community/pytest-ansible/blob/v2.2.4/setup.py#L124
    broken = lib.versionAtLeast ansible.version "2.10";
    maintainers = with maintainers; [ costrouc ];
  };
}