def test_threaded(testbot):
def threadtest(signal):
# If a new event loop isn't created for the thread, this will crash
try:
assert threading.current_thread() != threading.main_thread()
testbot.load_data()
except Exception as error:
# Pytest will catch this stdout and print it and the signal will
# fail the test
print(error)
signal.clear()
else:
signal.set()
signal = threading.Event()
thread = threading.Thread(target=threadtest, args=(signal, ))
thread.start()
thread.join()
assert signal.is_set()
评论列表
文章目录