MCPcopy
hub / github.com/pytest-dev/pytest / norm_sep

Function norm_sep

src/_pytest/nodes.py:53–63  ·  view source on GitHub ↗

Normalize path separators to forward slashes for nodeid compatibility. Replaces backslashes with forward slashes. This handles both Windows native paths and cross-platform data (e.g., Windows paths in serialized test reports when running on Linux). :param path: A path string or Pat

(path: str | os.PathLike[str])

Source from the content-addressed store, hash-verified

51
52
53def norm_sep(path: str | os.PathLike[str]) -> str:
54 """Normalize path separators to forward slashes for nodeid compatibility.
55
56 Replaces backslashes with forward slashes. This handles both Windows native
57 paths and cross-platform data (e.g., Windows paths in serialized test reports
58 when running on Linux).
59
60 :param path: A path string or PathLike object.
61 :returns: String with all backslashes replaced by forward slashes.
62 """
63 return os.fspath(path).replace("\\", SEP)
64
65
66tracebackcutdir = Path(_pytest.__file__).parent

Callers 1

__init__Method · 0.85

Calls 1

fspathMethod · 0.80

Tested by

no test coverage detected