Fix Test failure with cowsay installed/present (#83347)

pull/83358/head
MajesticMagikarpKing 4 months ago committed by GitHub
parent b8f1add983
commit e07b4edc54
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):
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

Loading…
Cancel
Save