[Python] Pytest - how to skip tests unless you declare an option/flag?

Discussão em 'Python' iniciado por Stack, Julho 21, 2025.

  1. Stack

    Stack Membro Participativo

    I have some unit tests, but I'm looking for a way to tag some specific unit tests to have them skipped unless you declare an option when you call the tests.

    Example: If I call pytest test_reports.py, I'd want a couple specific unit tests to not be run.

    But if I call pytest -<something> test_reports, then I want all my tests to be run.

    I looked into the @pytest.mark.skipif(condition) tag but couldn't quite figure it out, so not sure if I'm on the right track or not. Any guidance here would be great!

    Continue reading...

Compartilhe esta Página