mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-02 15:21:25 -07:00
pip module: fix TypeError (#31395)
* pip: add test: an error occurs when pip not found * pip: fix TypeError exception when pip executable isn't found
This commit is contained in:
parent
5e9384300d
commit
1c9bffe248
6 changed files with 31 additions and 5 deletions
26
test/units/modules/packaging/language/test_pip.py
Normal file
26
test/units/modules/packaging/language/test_pip.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
import json
|
||||
|
||||
from ansible.compat.tests import unittest
|
||||
from ansible.compat.tests.mock import patch
|
||||
from ansible.module_utils import basic
|
||||
|
||||
from ansible.modules.packaging.language import pip
|
||||
|
||||
from ..utils import (set_module_args, AnsibleFailJson, exit_json, fail_json)
|
||||
|
||||
|
||||
class TestPip(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.mock_ansible_module = patch.multiple(basic.AnsibleModule, exit_json=exit_json, fail_json=fail_json)
|
||||
self.mock_ansible_module.start()
|
||||
self.addCleanup(self.mock_ansible_module.stop)
|
||||
|
||||
@patch.object(basic.AnsibleModule, 'get_bin_path')
|
||||
def test_failure_when_pip_absent(self, mock_get_bin_path):
|
||||
|
||||
mock_get_bin_path.return_value = None
|
||||
|
||||
with self.assertRaises(AnsibleFailJson):
|
||||
set_module_args({'name': 'six'})
|
||||
pip.main()
|
Loading…
Add table
Add a link
Reference in a new issue