diff options
Diffstat (limited to 'test/units/plugins/inventory/test_script.py')
-rw-r--r-- | test/units/plugins/inventory/test_script.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/test/units/plugins/inventory/test_script.py b/test/units/plugins/inventory/test_script.py index 9f75199f..89eb4f5b 100644 --- a/test/units/plugins/inventory/test_script.py +++ b/test/units/plugins/inventory/test_script.py @@ -28,7 +28,7 @@ from ansible import constants as C from ansible.errors import AnsibleError from ansible.plugins.loader import PluginLoader from units.compat import unittest -from ansible.module_utils._text import to_bytes, to_native +from ansible.module_utils.common.text.converters import to_bytes, to_native class TestInventoryModule(unittest.TestCase): @@ -103,3 +103,11 @@ class TestInventoryModule(unittest.TestCase): self.inventory_module.parse(self.inventory, self.loader, '/foo/bar/foobar.py') assert e.value.message == to_native("failed to parse executable inventory script results from " "/foo/bar/foobar.py: needs to be a json dict\ndummyédata\n") + + def test_get_host_variables_subprocess_script_raises_error(self): + self.popen_result.returncode = 1 + self.popen_result.stderr = to_bytes("dummyéerror") + + with pytest.raises(AnsibleError) as e: + self.inventory_module.get_host_variables('/foo/bar/foobar.py', 'dummy host') + assert e.value.message == "Inventory script (/foo/bar/foobar.py) had an execution error: dummyéerror" |