Fix error message given by ansible.module_utils.facts.timeout.timeout (#83945)

* Update unit test

Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
pull/84050/head
Sloane Hertel 2 months ago committed by GitHub
parent 9406ed3109
commit ee9e6130a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,2 @@
bugfixes:
- Use the requested error message in the ansible.module_utils.facts.timeout timeout function instead of hardcoding one.

@ -48,7 +48,7 @@ def timeout(seconds=None, error_message="Timer expired"):
return res.get(timeout_value) return res.get(timeout_value)
except multiprocessing.TimeoutError: except multiprocessing.TimeoutError:
# This is an ansible.module_utils.common.facts.timeout.TimeoutError # This is an ansible.module_utils.common.facts.timeout.TimeoutError
raise TimeoutError('Timer expired after %s seconds' % timeout_value) raise TimeoutError(f'{error_message} after {timeout_value} seconds')
finally: finally:
pool.terminate() pool.terminate()

@ -272,9 +272,7 @@ def test_get_mount_size_timeout(monkeypatch, set_file_content, on_timeout, shoul
raise Exception("Timeout failed") raise Exception("Timeout failed")
monkeypatch.setattr(mount_facts, "get_mount_size", mock_slow_function) monkeypatch.setattr(mount_facts, "get_mount_size", mock_slow_function)
# FIXME match = r"Timed out getting mount size for mount /proc \(type proc\) after 0.1 seconds"
# match = "Timed out getting mount size .*"
match = "Timer expired after 0.1 seconds"
if should_raise: if should_raise:
with pytest.raises(AnsibleFailJson, match=match): with pytest.raises(AnsibleFailJson, match=match):

Loading…
Cancel
Save