Fix parametrize(... ids=<function>) when the function returns non-strings.

This commit is contained in:
Anthony Sottile
2019-02-07 11:07:20 -08:00
parent 526f4a95cc
commit 4c7ddb8d9b
3 changed files with 20 additions and 6 deletions

View File

@@ -418,6 +418,21 @@ class TestMetafunc(object):
]
)
def test_parametrize_ids_returns_non_string(self, testdir):
testdir.makepyfile(
"""\
import pytest
def ids(d):
return d
@pytest.mark.parametrize("arg", ({1: 2}, {3, 4}), ids=ids)
def test(arg):
assert arg
"""
)
assert testdir.runpytest().ret == 0
def test_idmaker_with_ids(self):
from _pytest.python import idmaker