def test_monitor_thread(): """Test dummy monitoring thread""" monitor = TMonitor(FakeTqdm, 10) # Test if alive, then killed assert monitor.report() monitor.exit() assert not monitor.report() assert not monitor.is_alive() del monitor
def test_monitor_thread(): """Test dummy monitoring thread""" maxinterval = 10 # Setup a discrete timer timer = DiscreteTimer() TMonitor._time = timer.time # And a fake sleeper sleeper = FakeSleep(timer) TMonitor._event = make_create_fake_sleep_event(sleeper.sleep) # Instanciate the monitor monitor = TMonitor(FakeTqdm, maxinterval) # Test if alive, then killed assert monitor.report() monitor.exit() timer.sleep(maxinterval * 2) # need to go out of the sleep to die assert not monitor.report() # assert not monitor.is_alive() # not working dunno why, thread not killed del monitor