Added test_pytest_make_parametrize_id
This commit is contained in:
parent
79927428d1
commit
b9faf78d51
|
@ -1133,7 +1133,7 @@ else:
|
||||||
return val.encode('unicode-escape')
|
return val.encode('unicode-escape')
|
||||||
|
|
||||||
|
|
||||||
def _idval(val, argname, idx, idfn, config):
|
def _idval(val, argname, idx, idfn, config=None):
|
||||||
if idfn:
|
if idfn:
|
||||||
try:
|
try:
|
||||||
s = idfn(val)
|
s = idfn(val)
|
||||||
|
@ -1159,7 +1159,7 @@ def _idval(val, argname, idx, idfn, config):
|
||||||
return val.__name__
|
return val.__name__
|
||||||
return str(argname)+str(idx)
|
return str(argname)+str(idx)
|
||||||
|
|
||||||
def _idvalset(idx, valset, argnames, idfn, ids, config):
|
def _idvalset(idx, valset, argnames, idfn, ids, config=None):
|
||||||
if ids is None or ids[idx] is None:
|
if ids is None or ids[idx] is None:
|
||||||
this_id = [_idval(val, argname, idx, idfn, config)
|
this_id = [_idval(val, argname, idx, idfn, config)
|
||||||
for val, argname in zip(valset, argnames)]
|
for val, argname in zip(valset, argnames)]
|
||||||
|
|
|
@ -1156,3 +1156,21 @@ class TestMarkersWithParametrization:
|
||||||
""")
|
""")
|
||||||
reprec = testdir.inline_run()
|
reprec = testdir.inline_run()
|
||||||
reprec.assertoutcome(passed=2)
|
reprec.assertoutcome(passed=2)
|
||||||
|
|
||||||
|
def test_pytest_make_parametrize_id(self, testdir):
|
||||||
|
testdir.makeconftest("""
|
||||||
|
def pytest_make_parametrize_id(val):
|
||||||
|
return str(val * 2)
|
||||||
|
""")
|
||||||
|
testdir.makepyfile("""
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("x", range(2))
|
||||||
|
def test_func(x):
|
||||||
|
pass
|
||||||
|
""")
|
||||||
|
result = testdir.runpytest("-v")
|
||||||
|
result.stdout.fnmatch_lines([
|
||||||
|
"*test_func*0*PASS*",
|
||||||
|
"*test_func*2*PASS*",
|
||||||
|
])
|
||||||
|
|
Loading…
Reference in New Issue