I'm pretty new at unit testing using unit test module and i need to test a class which using the threading module. I didn't really find any solution on what is the best way to unit a class using threads. I start to test if the thread was called (i.e. alive) but then I saw there is no method to kill a thread. I need as week to be sure the code in thread in doing what it's supposed to do. Do i need to use the thread for that or should I test only the function by itself?
Thanks for your help!
Here is my code (the interesting part):
class VideoLoader(Node):
# some code
def execute(self):
self.thread1 = Thread(target = run_resizer, args = (self,))
def run_resizer(node):
while True:
while not len(node.frames_to_resize):
time.sleep(0.001)
node.frames.append(resize({'height': 400, 'width': 500))