Skip to content

Commit 78052bd

Browse files
Refactor get_node_path function to handle fspath greedy access (microsoft#22384)
closes microsoft#20830 --------- Co-authored-by: Karthik Nadig <[email protected]>
1 parent 491c2c8 commit 78052bd

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pythonFiles/vscode_pytest/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,13 @@ class EOTPayloadDict(TypedDict):
633633

634634
def get_node_path(node: Any) -> pathlib.Path:
635635
"""A function that returns the path of a node given the switch to pathlib.Path."""
636-
return getattr(node, "path", pathlib.Path(node.fspath))
636+
path = getattr(node, "path", None) or pathlib.Path(node.fspath)
637+
638+
if not path:
639+
raise VSCodePytestError(
640+
f"Unable to find path for node: {node}, node.path: {node.path}, node.fspath: {node.fspath}"
641+
)
642+
return path
637643

638644

639645
__socket = None

0 commit comments

Comments
 (0)