From bd2e26a20fd85869cbebfcd52a95ddada33c8f0a Mon Sep 17 00:00:00 2001 From: merwanehamadi Date: Fri, 9 Jun 2023 07:43:56 -0700 Subject: [PATCH] Inform users that challenges can be flaky (#4616) * Inform users that challenges can be flaky * Update challenge_decorator.py --- .../challenges/challenge_decorator/challenge_decorator.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/challenges/challenge_decorator/challenge_decorator.py b/tests/challenges/challenge_decorator/challenge_decorator.py index 1d1fbf91..5ef7f19e 100644 --- a/tests/challenges/challenge_decorator/challenge_decorator.py +++ b/tests/challenges/challenge_decorator/challenge_decorator.py @@ -15,6 +15,8 @@ MAX_LEVEL_TO_IMPROVE_ON = ( 1 # we will attempt to beat 1 level above the current level for now. ) +CHALLENGE_FAILED_MESSAGE = "Challenges can sometimes fail randomly, please run this test again and if it fails reach out to us on https://discord.gg/autogpt and reach out to us on the 'challenges' channel to let us know the challenge you're struggling with." + def challenge(func: Callable[..., Any]) -> Callable[..., None]: @wraps(func) @@ -34,7 +36,9 @@ def challenge(func: Callable[..., Any]) -> Callable[..., None]: func(*args, **kwargs) challenge.succeeded = True except AssertionError as err: - original_error = err + original_error = AssertionError( + f"{CHALLENGE_FAILED_MESSAGE}\n{err}" + ) challenge.succeeded = False else: challenge.skipped = True @@ -54,7 +58,6 @@ def challenge(func: Callable[..., Any]) -> Callable[..., None]: pytest.xfail("Challenge failed") if original_error: raise original_error - raise AssertionError("Challenge failed") run_remaining -= 1 return wrapper