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:
parent
b24c63b55f
commit
a849fe6991
2 changed files with 12 additions and 1 deletions
|
@ -68,7 +68,7 @@ class Connection(ConnectionBase):
|
||||||
super(Connection, self)._connect()
|
super(Connection, self)._connect()
|
||||||
|
|
||||||
if not HAS_LIBLXC:
|
if not HAS_LIBLXC:
|
||||||
msg = "lxc bindings for python2 are not installed"
|
msg = "lxc python bindings are not installed"
|
||||||
raise errors.AnsibleError(msg)
|
raise errors.AnsibleError(msg)
|
||||||
|
|
||||||
if self.container:
|
if self.container:
|
||||||
|
|
|
@ -11,6 +11,7 @@ import sys
|
||||||
|
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
|
|
||||||
|
from ansible.errors import AnsibleError
|
||||||
from ansible.playbook.play_context import PlayContext
|
from ansible.playbook.play_context import PlayContext
|
||||||
from ansible.plugins.loader import connection_loader
|
from ansible.plugins.loader import connection_loader
|
||||||
from ansible_collections.community.general.tests.unit.compat import mock
|
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)
|
conn = connection_loader.get('lxc', play_context, in_stream)
|
||||||
assert conn
|
assert conn
|
||||||
assert isinstance(conn, lxc.Connection)
|
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()
|
||||||
|
|
Loading…
Reference in a new issue