Fix node ids which contain a parametrized empty-string variable

This commit is contained in:
Anthony Sottile 2020-01-28 13:27:54 -08:00
parent e440b43258
commit abd5fc80e8
3 changed files with 15 additions and 1 deletions

View File

@ -0,0 +1 @@
Fix node ids which contain a parametrized empty-string variable.

View File

@ -873,7 +873,7 @@ class CallSpec2:
@property
def id(self):
return "-".join(map(str, filter(None, self._idlist)))
return "-".join(map(str, self._idlist))
def setmulti2(self, valtypes, argnames, valset, id, marks, scopenum, param_index):
for arg, val in zip(argnames, valset):

View File

@ -492,6 +492,19 @@ class TestFunction:
)
assert "foo" in keywords[1] and "bar" in keywords[1] and "baz" in keywords[1]
def test_parametrize_with_empty_string_arguments(self, testdir):
items = testdir.getitems(
"""\
import pytest
@pytest.mark.parametrize('v', ('', ' '))
@pytest.mark.parametrize('w', ('', ' '))
def test(v, w): ...
"""
)
names = {item.name for item in items}
assert names == {"test[-]", "test[ -]", "test[- ]", "test[ - ]"}
def test_function_equality_with_callspec(self, testdir):
items = testdir.getitems(
"""