1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Update liblxc error message

The error is not specific to python2, so remove the version. Also add
a test for it.
This commit is contained in:
corubba 2023-10-08 18:30:13 +02:00
parent b24c63b55f
commit a849fe6991
2 changed files with 12 additions and 1 deletions

View file

@ -68,7 +68,7 @@ class Connection(ConnectionBase):
super(Connection, self)._connect()
if not HAS_LIBLXC:
msg = "lxc bindings for python2 are not installed"
msg = "lxc python bindings are not installed"
raise errors.AnsibleError(msg)
if self.container:

View file

@ -11,6 +11,7 @@ import sys
from io import StringIO
from ansible.errors import AnsibleError
from ansible.playbook.play_context import PlayContext
from ansible.plugins.loader import connection_loader
from ansible_collections.community.general.tests.unit.compat import mock
@ -60,3 +61,13 @@ class TestLXCConnectionClass():
conn = connection_loader.get('lxc', play_context, in_stream)
assert conn
assert isinstance(conn, lxc.Connection)
@pytest.mark.parametrize('lxc', [False], indirect=True)
def test_lxc_connection_liblxc_error(self, lxc):
"""Test that on connect an error is thrown if liblxc is not present."""
play_context = PlayContext()
in_stream = StringIO()
conn = connection_loader.get('lxc', play_context, in_stream)
with pytest.raises(AnsibleError, match='lxc python bindings are not installed'):
conn._connect()