'Utility function that helps with the assertions.'

def _check(self, timeout, sleep, result, arg='OK'):

    if (timeout > sleep):
        x = None
    elif isinstance(result, TimeLimitExpired):
        x = result
    else:
        x = TimeLimitExpired
    self.assertTrue((result is x))
