Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Py.Test getting remaining test case count

Tags:

python

pytest

Is there a way to get the test cases that are yet to be executed with Py.Test (in a py.test setup fixture with function scope or in pytest_exception_interact) .

When a test case is failed, I am setting a global flag in my conftest to indicate the test failure and reset the application to a default state in pytest_exception_interact and in the function setup of next function ,I validate this flag to run a set of pre-conditions before executing the tests. Now , I do not want to run the actions i am peforming when the last test case fails.

like image 720
Sanju Avatar asked Jul 25 '26 22:07

Sanju


1 Answers

I was able to get the information of total tests in a module with the argument node (node.parent._collected ), but I could not find a way to check if the tests are already executed or not . Right now , all I am doing is check the index of current test in this list and see how many are still in the queue to be executed .

def pytest_exception_interact(node, call, report):
    pass

If anybody, has a better solution kindly let me know.

like image 68
Sanju Avatar answered Jul 27 '26 11:07

Sanju



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!