Skip to content

Commit 209e6a2

Browse files
authored
Only show args for pytest parameterized test (microsoft#19479)
The rest of the name is redundant because it's nested under the un-parameterized test name.
1 parent f44ded1 commit 209e6a2

3 files changed

Lines changed: 64 additions & 62 deletions

File tree

‎pythonFiles/testing_tools/adapter/pytest/_pytest_item.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,12 @@ def parse_item(
168168
)
169169
nodeid = "{}{}".format(parentid, parameterized)
170170
parents = [(parentid, item.originalname, kind)] + parents
171+
name = parameterized[1:-1] or "<empty>"
171172
else:
172173
(nodeid, parents, fileid, testfunc, parameterized) = _parse_node_id(
173174
item.nodeid, kind
174175
)
176+
name = item.name
175177

176178
# Note: testfunc does not necessarily match item.function.__name__.
177179
# This can result from importing a test function from another module.
@@ -221,7 +223,7 @@ def parse_item(
221223

222224
test = SingleTestInfo(
223225
id=nodeid,
224-
name=item.name,
226+
name=name,
225227
path=SingleTestPath(
226228
root=testroot,
227229
relfile=relfile,

‎pythonFiles/tests/testing_tools/adapter/pytest/test_discovery.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ def test_modifyitems(self):
691691
],
692692
test=info.SingleTestInfo(
693693
id="./test_spam.py::test_each[10-10]",
694-
name="test_each[10-10]",
694+
name="10-10",
695695
path=info.SingleTestPath(
696696
root=testroot,
697697
relfile=relfile1,
@@ -760,7 +760,7 @@ def test_modifyitems(self):
760760
],
761761
test=info.SingleTestInfo(
762762
id="./x/y/z/test_eggs.py::All::BasicTests::test_each[1+2-3]",
763-
name="test_each[1+2-3]",
763+
name="1+2-3",
764764
path=info.SingleTestPath(
765765
root=testroot,
766766
relfile=adapter_util.fix_relpath(relfile2),
@@ -1033,7 +1033,7 @@ def test_nested_brackets(self):
10331033
],
10341034
test=info.SingleTestInfo(
10351035
id="./x/y/z/test_eggs.py::SpamTests::test_spam[a-[b]-c]",
1036-
name="test_spam[a-[b]-c]",
1036+
name="a-[b]-c",
10371037
path=info.SingleTestPath(
10381038
root=testroot,
10391039
relfile=adapter_util.fix_relpath(relfile),

0 commit comments

Comments
 (0)