I have a function that iterates through tests and executes them. Before executing each test, it calls a function confirm_execute()
to check if the tests have been cancelled. confirm_execute()
is shown below (pardon the mess of debugging messages):
def confirm_execute(self):
self._update_hil_status()
status = self.hil_status['status']
print 'STATUS =', status
if status == 'TESTING':
return True
elif status == 'CANCEL':
print '##### Cancelling #####'
return False
elif status == 'REQUEST_STOP':
print '##### Stopping tests #####'
self._set_hil_status(status='STOPPED')
elif status == 'STOPPED':
time.sleep(5)
elif status == 'RESUME':
print '##### Resuming tests #####'
self._set_hil_status(status='TESTING')
else:
print '##### Invalid status {} - setting stop status #####'.format(status)
self._set_hil_status(status='STOPPED')
self.confirm_execute() # only exit if status is testing or cancel
The portion of function that checks for permission before executing a test is here:
allow = self.status.confirm_execute()
if allow:
print 'continue: {}'.format(allow)
# run a test
else:
print 'cancel: {}'.format(allow)
# clean up
Here's the issue: when I set the status
to CANCEL
, confirm_execute
seems to return None
instead of False
. Here's the output on the console when I stop a set of tests and then attempt to cancel:
STATUS = REQUEST_STOP
##### Stopping tests #####
SETTING STOPPED
STATUS = STOPPED
STATUS = STOPPED
STATUS = CANCEL
##### Cancelling #####
cancel: None
Note that I get the ##### Cancelling #####
message, which means that I should be returning False
. However, the value of allow
received seems to be None
.
What simple mistake am I making?