My multithreaded app suffered from a bug where any abnormal termination of the main thread (e.g., an uncaught exception or some signals) caused a deadlock on one of the other threads, and prevented the process from cleanly exiting. I fixed that issue, but I wanted to add a test to prevent regression.
However, I cannot figure out how to simulate abnormal termination in pytest.
If I just raise an exception in a test, the abnormal termination is simulated perfectly, but of course pytest reports an error even when everything works as intended.
On the other hand, if I surround the raising of an exception with pytest.raises
context manager, the main thread is not abnormally terminated since pytest catches the exception.
Aucun commentaire:
Enregistrer un commentaire