Friday, 5 August 2022

How do I reset Python runtime between pytest test_functions?

I am using pytest to test code that creates a prometheus Python client to export metrics.

Between the test functions the prometheus client does not reset (because it has an internal state) which screws up my tests.

I am looking for a way to basically get a new Pyhon runtime before all test function calls. That way the internal state of the prometheus client would hopefully reset to a state that it had when the Python runtime started to execute my tests.

I already tried importlib.reload() but that does not work.



from How do I reset Python runtime between pytest test_functions?

No comments:

Post a Comment