Skip to content

Question/enhancement: (optionally) report failure if parametrize produces no arguments #3849

@sambarluc

Description

@sambarluc

I noticed a potentially dangerous behaviour of parametrized tests. I have a parametrized test where arguments have to be filled in some "complicated" fashion, let's say via a call to _get_arguments():

import pytest
from mymodule import do_stuff

@pytest.mark.parametrize("argument", _get_arguments())
def test_arg_returns_nonempty(argument):
    assert do_stuff(argument)

It may happen that _get_arguments() returns an empty list. In this case, the test is skipped. However, it may be better sometimes to mark the test as failed or errored in this case. Google suggests this is not currently possible via pytest, is this correct? Clearly, checks can be put elsewhere, but I think it would be useful, and less error prone, to be able to say something like noskip via another mark, or via an option of parametrize.

Thanks for the good work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: reportingrelated to terminal output and user-facing messages and errorstopic: tracebacksrelated to displaying and handling of tracebackstype: enhancementnew feature or API change, should be merged into features branchtype: feature-branchnew feature or API change, should be merged into features branch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions