Skip to content

Fix node ids which contain a parametrized empty-string variable #6607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/6597.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix node ids which contain a parametrized empty-string variable.
2 changes: 1 addition & 1 deletion src/_pytest/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ def getparam(self, name):

@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):
Expand Down
13 changes: 13 additions & 0 deletions testing/python/collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,19 @@ def test_function(arg):
)
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(
"""
Expand Down