[stable-2.17] Fix Test failure with cowsay installed/present (#83351)

(cherry picked from commit e07b4edc54)

Co-authored-by: MajesticMagikarpKing <69774548+yctomwang@users.noreply.github.com>
pull/83398/head
Abhijeet Kasurde 6 months ago committed by GitHub
parent ca871fbc2c
commit 92630e54ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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.

@ -10,13 +10,12 @@ from unittest.mock import MagicMock
def test_display_with_fake_cowsay_binary(capsys, mocker): def test_display_with_fake_cowsay_binary(capsys, mocker):
display = Display()
mocker.patch("ansible.constants.ANSIBLE_COW_PATH", "./cowsay.sh") mocker.patch("ansible.constants.ANSIBLE_COW_PATH", "./cowsay.sh")
mock_popen = MagicMock() mock_popen = MagicMock()
mock_popen.return_value.returncode = 1 mock_popen.return_value.returncode = 1
mocker.patch("subprocess.Popen", mock_popen) mocker.patch("subprocess.Popen", mock_popen)
display = Display()
assert not hasattr(display, "cows_available") assert not hasattr(display, "cows_available")
assert display.b_cowsay is None assert display.b_cowsay is None

Loading…
Cancel
Save