def test_infinit_registration_retries(self): netutil = NetUtil() netutil.CONNECT_SERVER_RETRY_INTERVAL_SEC = 0.05 thread = Thread(target=netutil.try_to_connect, args=(BAD_URL, -1)) thread.start() time.sleep(0.25) # I have to stop the thread anyway, so I'll check results later threadWasAlive = thread.isAlive() netutil.DEBUG_STOP_RETRIES_FLAG = True time.sleep(0.5) # Checking results before thread stop self.assertEquals(threadWasAlive, True, "Thread should still be retrying to connect") # Checking results after thread stop self.assertEquals(thread.isAlive(), False, "Thread should stop now")
def test_registration_retries(self): netutil = NetUtil() netutil.CONNECT_SERVER_RETRY_INTERVAL_SEC = 0.05 retries = netutil.try_to_connect(BAD_URL, 3) self.assertEquals(retries, 3)