From c37a9e3e23abc934996ae0c221203cdcd4973941 Mon Sep 17 00:00:00 2001 From: JonahStanley Date: Thu, 11 Jul 2013 16:37:39 -0400 Subject: [PATCH] Refactored problem_setup to use retry_on_exception --- .../courseware/features/problems_setup.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/lms/djangoapps/courseware/features/problems_setup.py b/lms/djangoapps/courseware/features/problems_setup.py index 96dd3cee40..1805da55d0 100644 --- a/lms/djangoapps/courseware/features/problems_setup.py +++ b/lms/djangoapps/courseware/features/problems_setup.py @@ -313,18 +313,13 @@ def assert_checked(problem_type, choices): all_choices = ['choice_0', 'choice_1', 'choice_2', 'choice_3'] for this_choice in all_choices: - attempt = 0 - while attempt < 5: - try: - element = world.css_find(inputfield(problem_type, choice=this_choice)) - if this_choice in choices: - assert element.checked - else: - assert not element.checked - break - except: - attempt += 1 - assert_true(attempt < 5, "Could not access {}".format(element)) + def check_problem(): + element = world.css_find(inputfield(problem_type, choice=this_choice)) + if this_choice in choices: + assert element.checked + else: + assert not element.checked + world.retry_on_exception(check_problem) def assert_textfield(problem_type, expected_text, input_num=1):