From 2e0e5996388fc215ef0f0e28a47e0b96fa57e67b Mon Sep 17 00:00:00 2001 From: pkoprda <47797196+pkoprda@users.noreply.github.com> Date: Fri, 20 Dec 2024 01:36:04 +0100 Subject: [PATCH] test(client): Fix unusual race condition in tests (#4316) This change fixes an occasional test failure due to a race condition with the gpg command. The tests in `test_crypto.py` were updated to include the `ignore_errors=True` parameter in `shutil.rmtree(home)`. Signed-off-by: pkoprda (cherry picked from commit 91adb4ece594f0796c65fd3bdd618462ca49eea8) --- insights/tests/client/test_crypto.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/insights/tests/client/test_crypto.py b/insights/tests/client/test_crypto.py index 7de4df2b94..5668d09eef 100644 --- a/insights/tests/client/test_crypto.py +++ b/insights/tests/client/test_crypto.py @@ -147,7 +147,7 @@ def test_valid_signature(): signature=home + "/file.txt.asc", key=home + "/key.public.gpg", ) - shutil.rmtree(home) + shutil.rmtree(home, ignore_errors=True) # Verify results assert True is result.ok @@ -182,7 +182,7 @@ def test_no_file(file): assert result.return_code > 0 assert "file '{path}' does not exist".format(path=home + file) == result.stderr - shutil.rmtree(home) + shutil.rmtree(home, ignore_errors=True) @mock.patch("insights.client.crypto.GPGCommand.TEMPORARY_GPG_HOME_PARENT_DIRECTORY", "/tmp/") @@ -220,7 +220,7 @@ def test_invalid_signature(): signature=home + "/file.txt.asc", key=home + "/key.public.gpg", ) - shutil.rmtree(home) + shutil.rmtree(home, ignore_errors=True) # Verify results assert not result.ok