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

test: fix flaky test #3314

Merged
merged 2 commits into from
Jul 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -394,13 +394,17 @@ def test_setup_once(
else:
fake_set_context.assert_not_called()

if warning_called:
correct_warning_found = False
def invalid_value_warning_calls():
"""
Iterator that yields True if the warning was called with the expected message.
Written as a generator function, rather than a list comprehension, to allow
us to handle exceptions that might be raised during the iteration if the
warning call was not as expected.
"""
for call in fake_warning.call_args_list:
if call[0][0].startswith("Invalid value for cloud_provider:"):
correct_warning_found = True
break
try:
yield call[0][0].startswith("Invalid value for cloud_provider:")
except (IndexError, KeyError, TypeError, AttributeError):
...

assert correct_warning_found
else:
fake_warning.assert_not_called()
assert warning_called == any(invalid_value_warning_calls())
Loading