You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible/test/units/utils/display/test_broken_cowsay.py

23 lines
634 B
Python

# -*- coding: utf-8 -*-
# Copyright (c) 2021 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import annotations
from ansible.utils.display import Display
from unittest.mock import MagicMock
def test_display_with_fake_cowsay_binary(capsys, mocker):
display = Display()
mocker.patch("ansible.constants.ANSIBLE_COW_PATH", "./cowsay.sh")
mock_popen = MagicMock()
mock_popen.return_value.returncode = 1
mocker.patch("subprocess.Popen", mock_popen)
assert not hasattr(display, "cows_available")
assert display.b_cowsay is None