What are the ways to check that Python sub processes are running in a set default time, not exceeding the limit? Any Pytest/Mock/assert ideas?

Viewed 15

I am trying to get a way which can have a pytest function defined that checks the running time limit of python subprocesses.

1 Answers

You cannot find out anything about the running time of a subprocess unless you actually run that subprocess, so I do not think this is a case for mocking.

Your test needs to

  • run the subprocess,
  • wait for the allowed time, and
  • fail if the subprocess has not finished by then.

You can speed up the test by making sure it is notified (and then terminates successfully) as soon as the subprocess finishes.

Related