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

Discussão em 'Python' iniciado por Stack, Outubro 1, 2024.

  1. Stack

    Stack Membro Participativo

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

    @pytest.mark.skipif('password' not in os.environ,
    reason='Environment variable "password" not set.')
    def test_1(mock):
    ....

    @pytest.mark.skipif('password' not in os.environ,
    reason='Environment variable "password" not set.')
    def test_2(mock):
    ....

    @pytest.mark.skipif('password' not in os.environ,
    reason='Environment variable "password" not set.')
    def test_3(mock):
    ....


    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?

    ====== 25 skipped in 5.96s =======

    Continue reading...

Compartilhe esta Página