def test_checking_not_failing(self):
     OriginalChecker = RCT.ResourcesCheckerThread.Checker
     RCT.ResourcesCheckerThread.Checker = FakeChecker
     original_sleep = RCT.sleep
     RCT.sleep = lambda *args : None
     try:
         RCT.reset()
         try:
             RCT.set_coordinator(original_coordinator, 10)
             time.sleep(0.01)
             self.assertTrue(counter > 2)
             self.assertTrue(right_coordinator)
             self.assertTrue(checked)
         finally:
             RCT.clean()
     finally:
         RCT.ResourcesCheckerThread.Checker = OriginalChecker
         RCT.sleep = original_sleep
 def test_checking_failing(self):
     OriginalChecker = RCT.ResourcesCheckerThread.Checker
     RCT.ResourcesCheckerThread.Checker = FakeFailingChecker
     original_sleep = RCT.sleep
     RCT.sleep = lambda *args : None
     try:
         RCT.reset()
         try:
             RCT.set_coordinator(original_coordinator, 10)
             initial_time = time.time()
             while not RCT.checker_thread.isAlive() and time.time() - initial_time <= 1:
                 time.sleep(0.02)
             # Now it's alive or more than 1 seconds have passed
             time.sleep(0.2)
             self.assertTrue(counter > 2) # It's still running
             self.assertTrue(right_coordinator)
             self.assertTrue(checked)
         finally:
             RCT.clean()
     finally:
         RCT.ResourcesCheckerThread.Checker = OriginalChecker
         RCT.sleep = original_sleep