New issue 719: pytest.mark.parametrize string-based parameter list doesn't 
handle single element tuples
https://bitbucket.org/pytest-dev/pytest/issue/719/pytestmarkparametrize-string-based

David Haney:

When specifying a `@pytest.mark.parametrize` element composed of a one-element 
tuple, I'm unable to use the string-based argument list, for example:

    @pytest.mark.parametrize("arg", scenarios)
    def test(arg):
        print(arg)
        assert(arg == "a") # this assert always fails

arg ends up being the tuple instead of the first item in the tuple (as I would 
expected based on tuples with more than one item. I also tried:

    @pytest.mark.parametrize("arg,", scenarios)

but that also associated the entire tuple with arg instead of the first 
element. I reverted back to the older model of specifying the arguments as a 
tuple:

    @pytest.mark.parametrize("arg,", scenarios)

Finally I switched back to the older style of using a tuple to specify the 
parameter list:

    @pytest.mark.parametrize(("arg",), scenarios)

This version worked. This seems to imply that there is either a bug/limitation 
in the new string-based parameter specification, or that there is still a 
use-case for the tuple-based parameter specification. It would be helpful if 
either the string-based implementation could be updated to handle this 
situation, or if the documentation could be updated to note when the 
tuple-based parameter specification is still needed.


_______________________________________________
pytest-commit mailing list
pytest-commit@python.org
https://mail.python.org/mailman/listinfo/pytest-commit

Reply via email to