Skip to content

Cannot pass unicode string in parameterized ids with pytest 3.0.2 and python 2 #1905

@philpep

Description

@philpep

Hi, since #1861 we cannot pass python 2 unicode object to parametrize():

sample code:

import pytest

@pytest.mark.parametrize('p', ['v'], ids=[u'v'])
def test_foo(p):
    pass

Error is:

v/local/lib/python2.7/site-packages/_pytest/python.py:105: in pytest_generate_tests
    metafunc.parametrize(*marker.args, **marker.kwargs)
v/local/lib/python2.7/site-packages/_pytest/python.py:837: in parametrize
    raise ValueError(msg % (saferepr(id_value), type(id_value).__name__))
E   ValueError: ids must be list of strings, found: 'v' (type: unicode)

Will this be fixed or should I encode my string only with python 2 (or both) ?

Thanks !

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: regressionindicates a problem that was introduced in a release which was working previously

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions