missing_required_lib: add information how to change Python interpreter (#60736)
* Add information how to change Python interpreter used by Ansible. * Update lib/ansible/module_utils/basic.py Co-Authored-By: Abhijeet Kasurde <akasurde@redhat.com> * Make test less dependent on exact message.
This commit is contained in:
parent
a9405456bc
commit
cd4736d893
2 changed files with 10 additions and 5 deletions
|
@ -567,7 +567,10 @@ def missing_required_lib(library, reason=None, url=None):
|
|||
if url:
|
||||
msg += " See %s for more info." % url
|
||||
|
||||
return msg + " Please read module documentation and install in the appropriate location"
|
||||
msg += (" Please read module documentation and install in the appropriate location."
|
||||
" If the required library is installed, but Ansible is using the wrong Python interpreter,"
|
||||
" please consult the documentation on ansible_python_interpreter")
|
||||
return msg
|
||||
|
||||
|
||||
class AnsibleFallbackNotFound(Exception):
|
||||
|
|
|
@ -108,10 +108,12 @@ def test_missing_ldap(laps_password):
|
|||
with pytest.raises(AnsibleLookupError) as err:
|
||||
lookup_loader.get('laps_password').run(["host"], domain="test")
|
||||
|
||||
assert str(err.value) == "Failed to import the required Python library (python-ldap) on %s's Python %s. See " \
|
||||
"https://pypi.org/project/python-ldap/ for more info. Please read module documentation " \
|
||||
"and install in the appropriate location. " \
|
||||
"Import Error: no import for you!" % (platform.node(), sys.executable)
|
||||
assert str(err.value).startswith(
|
||||
"Failed to import the required Python library (python-ldap) on %s's Python %s. See "
|
||||
"https://pypi.org/project/python-ldap/ for more info. Please "
|
||||
% (platform.node(), sys.executable)
|
||||
)
|
||||
assert str(err.value).endswith(". Import Error: no import for you!")
|
||||
|
||||
|
||||
def test_invalid_cert_mapping():
|
||||
|
|
Loading…
Reference in a new issue