2

I have a function which sometimes goes into the infinite loop. I want to write an integration test to check that that doesn't happen; i.e. the functions is too big/complex to modify, so testing has to be external. Basically, I know that it should always finish within x amount of time, if it takes more than x, it is in an infinite loop.

I'm using pytest as my testing framework. Is there a simple way to set a timer for functions execution?

I roughly understand how I can do it with threads/processes, but I was wondering if there is an existing approach.

Rizhiy
  • 775
  • 1
  • 9
  • 31
  • Does this answer your question? [Timeout on a function call](https://stackoverflow.com/questions/492519/timeout-on-a-function-call) – aaron Jun 25 '23 at 13:53
  • That seems to do what I want, if you post it as an answer I will accept it. – Rizhiy Jun 26 '23 at 00:10

0 Answers0