python - how to test if an interruptHandler works with pytest?
Asked Answered
N

0

7

I have an interrupt handler within a class and following method:

def interruptHandler(self, signal, frame):
    """ Catches SIGINT and SIGTERM to allow proper shutdown of all threads etc."""
    self.stopWorker()
    print("interrupt") # the print message is just for me to see if it works

when I press control + c I get the print message from my interruptHandler, so the method is fine. But when I write an pytest for it I dont know how to assert the SIGINT. And when I want to force the interrupt with

worker.interruptHandler(signal.sigint)

I get an error that I am missing the argument frame.

Neutral answered 21/11, 2018 at 10:28 Comment(1)
Possible duplicate of How to really test signal handling in Python?Believe

© 2022 - 2024 — McMap. All rights reserved.