summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSloane Hertel <19572925+s-hertel@users.noreply.github.com>2024-10-03 23:54:54 +0200
committerGitHub <noreply@github.com>2024-10-03 23:54:54 +0200
commitee9e6130a7d4a3765a6e18abdd979d244c3fce7c (patch)
treeb89a3c67ab8ab7c6fe3603b86b71fccf765d6757
parentansible-test - Update sanity tests and default Python (#83998) (diff)
downloadansible-ee9e6130a7d4a3765a6e18abdd979d244c3fce7c.tar.xz
ansible-ee9e6130a7d4a3765a6e18abdd979d244c3fce7c.zip
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>
-rw-r--r--changelogs/fragments/fix-module-utils-facts-timeout.yml2
-rw-r--r--lib/ansible/module_utils/facts/timeout.py2
-rw-r--r--test/units/modules/test_mount_facts.py4
3 files changed, 4 insertions, 4 deletions
diff --git a/changelogs/fragments/fix-module-utils-facts-timeout.yml b/changelogs/fragments/fix-module-utils-facts-timeout.yml
new file mode 100644
index 0000000000..3ecc95dfab
--- /dev/null
+++ b/changelogs/fragments/fix-module-utils-facts-timeout.yml
@@ -0,0 +1,2 @@
+bugfixes:
+ - Use the requested error message in the ansible.module_utils.facts.timeout timeout function instead of hardcoding one.
diff --git a/lib/ansible/module_utils/facts/timeout.py b/lib/ansible/module_utils/facts/timeout.py
index 5fb749fb6b..3b0476245b 100644
--- a/lib/ansible/module_utils/facts/timeout.py
+++ b/lib/ansible/module_utils/facts/timeout.py
@@ -48,7 +48,7 @@ def timeout(seconds=None, error_message="Timer expired"):
return res.get(timeout_value)
except multiprocessing.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:
pool.terminate()
diff --git a/test/units/modules/test_mount_facts.py b/test/units/modules/test_mount_facts.py
index 64f36a6934..2a2faec52c 100644
--- a/test/units/modules/test_mount_facts.py
+++ b/test/units/modules/test_mount_facts.py
@@ -272,9 +272,7 @@ def test_get_mount_size_timeout(monkeypatch, set_file_content, on_timeout, shoul
raise Exception("Timeout failed")
monkeypatch.setattr(mount_facts, "get_mount_size", mock_slow_function)
- # FIXME
- # match = "Timed out getting mount size .*"
- match = "Timer expired after 0.1 seconds"
+ match = r"Timed out getting mount size for mount /proc \(type proc\) after 0.1 seconds"
if should_raise:
with pytest.raises(AnsibleFailJson, match=match):