Skip to content

Commit d87811b

Browse files
committed
some improvements to pass tests
1 parent 3a06c03 commit d87811b

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

pythonFiles/testing_tools/adapter/pytest/_pytest_item.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,20 @@ def parse_item(
155155
"""
156156
# _debug_item(item, showsummary=True)
157157
kind, _ = _get_item_kind(item)
158-
# Skip plugin generated tests
158+
# Skip unexpected kind tests
159159
if kind is None:
160160
return None, None
161-
(nodeid, parents, fileid, testfunc, parameterized) = _parse_node_id(
162-
getattr(item, "_replace_nodeid", item.nodeid), kind
163-
)
161+
162+
if kind == "plugin_node":
163+
(nodeid, parents, fileid, testfunc, parameterized) = _parse_node_id(
164+
item.nodeid + "::" + item.location[2], kind
165+
)
166+
167+
else:
168+
169+
(nodeid, parents, fileid, testfunc, parameterized) = _parse_node_id(
170+
item.nodeid, kind
171+
)
164172
# Note: testfunc does not necessarily match item.function.__name__.
165173
# This can result from importing a test function from another module.
166174

@@ -209,7 +217,7 @@ def parse_item(
209217

210218
test = TestInfo(
211219
id=nodeid,
212-
name=getattr(item, "_replace_name", item.name),
220+
name=item.name,
213221
path=TestPath(
214222
root=testroot,
215223
relfile=relfile,
@@ -394,7 +402,7 @@ def _parse_node_id(
394402
parents.append(node)
395403
funcid, funcname, _ = node
396404
parameterized = testid[len(funcid) :]
397-
elif kind == "function":
405+
elif kind == "function" or kind == "plugin_node":
398406
funcname = name
399407
else:
400408
raise should_never_reach_here(
@@ -536,12 +544,12 @@ def _get_item_kind(item):
536544
elif isinstance(item, pytest.Function):
537545
# We *could* be more specific, e.g. "method", "subtest".
538546
return "function", False
539-
elif isinstance(item, _pytest.nodes.Item) and isinstance(
540-
item, _pytest.nodes.File
541-
):
542-
item._replace_nodeid = item.nodeid + "::" + item.location[2]
543-
item._replace_name = item.name[:-3].replace(PATH_SEP, ".")
544-
return "function", False
547+
elif isinstance(item, _pytest.nodes.Item) and isinstance(item, _pytest.nodes.File):
548+
# item._nodeid = item.nodeid + "::" + item.location[2]
549+
item.name = item.name.replace(PATH_SEP, ".")
550+
if item.name[-3:] == ".py":
551+
item.name = item.name[:-3]
552+
return "plugin_node", False
545553
else:
546554
return None, False
547555

0 commit comments

Comments
 (0)