jeudi 19 septembre 2019

How to decorate all the test methods in a test suite in pytest?

I recently started using pytest.

In my (currently small) test suite I need to decorate all the test methods with a helper function which will do some generic action.

Currently I am adding that to a helper module and importing that method in each and every test file.

Fixtures in pytest can be used as test function arguments and can be used inside the body of the test function.But it can't be used as a decorator for test methdos.

Is there any other elegant way like pytest-fixtures which can be added to conftest.py so that there is no need to import that function in all the test cases?

Aucun commentaire:

Enregistrer un commentaire