Skip to content
Advertisement

Skip all the test instead of decorating each test function with @pytest.mark.skipif()?

I have a pytest file which requires environment being set. So I add the following decorator on every function.

JavaScript

Is it a way to skip all the test instead of decorating each test function?

BTW, it just skip the tests with the following message. Is it a way to display a warning information of missing environment variable?

JavaScript

Advertisement

Answer

You can use a fixture with autouse=True that does the skipping for you:

JavaScript

Another possibility is to put the tests into a class and put the marker on the class instead, as mentioned by Luke Nelson in the comments.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement