lundi 4 décembre 2017

Python unit test last test detection?

Is there any way to check if there is another unit test to be executed? Since the user can pick and choose which unit tests he/she wants to be run, I want to call a function in the very last test case that is run (of the very last suite that is run) , so is there an equivalent of next() that I can check to see if there are any more test cases to be run? Or is there an attribute (or presence of an attribute) that I can use to detect if this is indeed the last test to be run?

I know that I can overwrite the tearDown() and tearDownClass() functions, but tearDownClass() still will call at the end of every test suite.

In the documentation, it states that “ Class and module level fixtures are implemented in TestSuite. When the test suite encounters a test from a new class then tearDownClass() from the previous class (if there is one) is called, followed by setUpClass() from the new class.” 
How does it detect that it has encountered a test from a new class? And can I leverage this to find if there is still a test to be run?

Aucun commentaire:

Enregistrer un commentaire