[stable-2.16] Fix Test failure with cowsay installed/present (#83350)

(cherry picked from commit e07b4edc54)

Co-authored-by: MajesticMagikarpKing <69774548+yctomwang@users.noreply.github.com>
This commit is contained in:
Abhijeet Kasurde
2024-06-06 15:59:26 -05:00
committed by GitHub
co-authored by MajesticMagikarpKing
parent a97e39b90f
commit 1ef184ba2d
2 changed files with 4 additions and 2 deletions
+3
View File
@@ -0,0 +1,3 @@
---
bugfixes:
- fixed unit test test_borken_cowsay to address mock not been properly applied when existing unix system already have cowsay installed.
@@ -12,13 +12,12 @@ 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)
display = Display()
assert not hasattr(display, "cows_available")
assert display.b_cowsay is None