Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unit tests to work with pytest >= 5.0 #60246

Merged
merged 1 commit into from Aug 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/units/executor/module_common/test_recursive_finder.py
Expand Up @@ -117,14 +117,14 @@ def test_module_utils_with_syntax_error(self, finder_containers):
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:
Expand Down
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion test/units/modules/network/ftd/test_ftd_file_download.py
Expand Up @@ -48,7 +48,7 @@ def test_module_should_fail_without_required_args(self, missing_arg):
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
Expand Down
2 changes: 1 addition & 1 deletion test/units/modules/network/ftd/test_ftd_file_upload.py
Expand Up @@ -30,7 +30,7 @@ def test_module_should_fail_without_required_args(self, missing_arg):
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
Expand Down
2 changes: 1 addition & 1 deletion test/units/plugins/terminal/test_junos.py
Expand Up @@ -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)