Skip to content

Commit

Permalink
Refactor get_node_path function to handle fspath greedy access (micro…
Browse files Browse the repository at this point in the history
…soft#22384)

closes microsoft#20830

---------

Co-authored-by: Karthik Nadig <kanadig@microsoft.com>
  • Loading branch information
eleanorjboyd and karthiknadig authored Oct 31, 2023
1 parent 491c2c8 commit 78052bd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pythonFiles/vscode_pytest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,13 @@ class EOTPayloadDict(TypedDict):

def get_node_path(node: Any) -> pathlib.Path:
"""A function that returns the path of a node given the switch to pathlib.Path."""
return getattr(node, "path", pathlib.Path(node.fspath))
path = getattr(node, "path", None) or pathlib.Path(node.fspath)

if not path:
raise VSCodePytestError(
f"Unable to find path for node: {node}, node.path: {node.path}, node.fspath: {node.fspath}"
)
return path


__socket = None
Expand Down

0 comments on commit 78052bd

Please sign in to comment.