Skip to content

Commit

Permalink
test(client): Fix unusual race condition in tests (#4316)
Browse files Browse the repository at this point in the history
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 <[email protected]>
(cherry picked from commit 91adb4e)
(cherry picked from commit 2e0e599)
  • Loading branch information
pkoprda authored and xiangce committed Jan 2, 2025
1 parent 8e9277d commit 9f8b829
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions insights/tests/client/test_crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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/")
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9f8b829

Please sign in to comment.