Short Question
Is it possible to re-attempt a unittest upon failure / error N number of times OR based on a predefined function. (Like a user's prompt)
Background
To avoid retyping an entire page of system information, please see SO question on passing data to unittests and on auto test discovery for more details on my physical set up.
Regarding the question at hand, I know I can do it by re-writting my test cases to loop until it gets the required results (see pseudo code below) then assert based off of this. However I rather not go and rewrite 100's of test cases.
I there will be someone that will point out that if a unittest fails, it should just fail and be done. I agree with this 100% if human error could be removed. This is a physical system that I am connected to and there are many times the leads from the digital multimeter are not connected well and it could fail because of a loose connection.
Pseudo Workaround
class Suite_VoltageRegulator(unittest.TestCase):
def test_voltage_5v_regulator(self):
keep_running = 'y'
error_detected = False
print '\n'
# Display User Test Configuration
msg = \
'1) Connect Front DMM GND(black) to the TP_COM\n' +\
'2) Connect Front DMM POS(red) to the TP-A\n' +\
'3) Ensure the DMM terminal button indicates FRONT'
continue_test = prompt.Prompt_Ok_Cancel('User Action Required!', msg)
if not continue_test:
self.assertTrue(False, 'User Canceled Test!')
while(keep_running == 'y'):
try: