diff --git a/test/units/executor/module_common/test_recursive_finder.py b/test/units/executor/module_common/test_recursive_finder.py index f2dc5e3183a..0866623b7e4 100644 --- a/test/units/executor/module_common/test_recursive_finder.py +++ b/test/units/executor/module_common/test_recursive_finder.py @@ -117,14 +117,14 @@ class TestRecursiveFinder(object): data = b'#!/usr/bin/python\ndef something(:\n pass\n' with pytest.raises(ansible.errors.AnsibleError) as exec_info: recursive_finder(name, data, *finder_containers) - assert 'Unable to import fake_module due to invalid syntax' in str(exec_info) + assert 'Unable to import fake_module due to invalid syntax' in str(exec_info.value) def test_module_utils_with_identation_error(self, finder_containers): name = 'fake_module' data = b'#!/usr/bin/python\n def something():\n pass\n' with pytest.raises(ansible.errors.AnsibleError) as exec_info: recursive_finder(name, data, *finder_containers) - assert 'Unable to import fake_module due to unexpected indent' in str(exec_info) + assert 'Unable to import fake_module due to unexpected indent' in str(exec_info.value) def test_from_import_toplevel_package(self, finder_containers, mocker): if PY2: diff --git a/test/units/module_utils/common/validation/test_check_type_int.py b/test/units/module_utils/common/validation/test_check_type_int.py index f07466dd184..22cedf61481 100644 --- a/test/units/module_utils/common/validation/test_check_type_int.py +++ b/test/units/module_utils/common/validation/test_check_type_int.py @@ -31,4 +31,4 @@ def test_check_type_int_fail(): for case in test_cases: with pytest.raises(TypeError) as e: check_type_int(case) - assert 'cannot be converted to an int' in to_native(e) + assert 'cannot be converted to an int' in to_native(e.value) diff --git a/test/units/modules/network/ftd/test_ftd_file_download.py b/test/units/modules/network/ftd/test_ftd_file_download.py index f11085e43de..ebb465e9eb5 100644 --- a/test/units/modules/network/ftd/test_ftd_file_download.py +++ b/test/units/modules/network/ftd/test_ftd_file_download.py @@ -48,7 +48,7 @@ class TestFtdFileDownload(object): with pytest.raises(AnsibleFailJson) as ex: self.module.main() - assert 'missing required arguments: %s' % missing_arg in str(ex) + assert 'missing required arguments: %s' % missing_arg in str(ex.value) def test_module_should_fail_when_no_operation_spec_found(self, connection_mock): connection_mock.get_operation_spec.return_value = None diff --git a/test/units/modules/network/ftd/test_ftd_file_upload.py b/test/units/modules/network/ftd/test_ftd_file_upload.py index bcb1ed994c3..addb0126018 100644 --- a/test/units/modules/network/ftd/test_ftd_file_upload.py +++ b/test/units/modules/network/ftd/test_ftd_file_upload.py @@ -30,7 +30,7 @@ class TestFtdFileUpload(object): with pytest.raises(AnsibleFailJson) as ex: self.module.main() - assert 'missing required arguments: %s' % missing_arg in str(ex) + assert 'missing required arguments: %s' % missing_arg in str(ex.value) def test_module_should_fail_when_no_operation_spec_found(self, connection_mock): connection_mock.get_operation_spec.return_value = None diff --git a/test/units/plugins/terminal/test_junos.py b/test/units/plugins/terminal/test_junos.py index d5ba4709e50..b863bb7b03a 100644 --- a/test/units/plugins/terminal/test_junos.py +++ b/test/units/plugins/terminal/test_junos.py @@ -52,4 +52,4 @@ def test_on_open_shell_raises_problem_setting_terminal_config(junos_terminal): with pytest.raises(AnsibleConnectionFailure) as exc: junos_terminal.on_open_shell() - assert 'unable to set terminal parameters' in str(exc) + assert 'unable to set terminal parameters' in str(exc.value)