pytest-dev/pytest · error · NotImplementedError
XXX win32
Error message
XXX win32
What it means
The Stat.owner property returns the owning username by calling pwd.getpwuid on the file's uid. On Windows there is no pwd module and no Unix uid concept, so the property raises NotImplementedError('XXX win32') at the top of the method. This is a known platform limitation of the legacy py.path.local API. The message is a placeholder indicating the feature was never implemented for Windows.
Source
Thrown at src/_pytest/_py/path.py:222
if TYPE_CHECKING:
@property
def size(self) -> int: ...
@property
def mtime(self) -> float: ...
def __getattr__(self, name: str) -> Any:
return getattr(self._osstatresult, "st_" + name)
def __init__(self, path, osstatresult):
self.path = path
self._osstatresult = osstatresult
@property
def owner(self):
if iswin32:
raise NotImplementedError("XXX win32")
import pwd
entry = error.checked_call(pwd.getpwuid, self.uid) # type:ignore[attr-defined,unused-ignore]
return entry[0]
@property
def group(self):
"""Return group name of file."""
if iswin32:
raise NotImplementedError("XXX win32")
import grp
entry = error.checked_call(grp.getgrgid, self.gid) # type:ignore[attr-defined,unused-ignore]
return entry[0]
def isdir(self):
return S_ISDIR(self._osstatresult.st_mode)
View on GitHub (pinned to 0d6fbdeffa)
Solutions
- Use pathlib + os module cross-platform: on Windows, owner resolution needs pywin32 or ctypes calls (GetFileSecurity).
- Skip the ownership assertion on Windows: `if sys.platform != 'win32': assert stat.owner == expected`.
- Use pytest.skip on Windows for tests that exercise Unix ownership semantics.
Example fix
# before
assert path.stat().owner == 'beagle'
# after
import sys, pytest
if sys.platform == 'win32':
pytest.skip('owner not supported on Windows')
assert path.stat().owner == 'beagle' Defensive patterns
Strategy: validation
Validate before calling
import sys
def can_resolve_owner() -> bool:
return sys.platform != 'win32' and getattr(sys, 'platform', '') != 'win32'
# usage
if can_resolve_owner():
assert path.stat().owner == expected_owner
else:
# Windows: owner not supported by py.path.local
pass Type guard
import sys
def supports_unix_owner() -> bool:
return sys.platform != 'win32' Prevention
- Guard owner assertions with sys.platform != 'win32'.
- Use pytest.skip on Windows for Unix-ownership tests.
- Migrate to pathlib; resolve ownership via pywin32 on Windows.
When it happens
Trigger: Calling path.stat().owner on Windows (sys.platform == 'win32' or os._name == 'nt'). Triggered at Stat.owner (src/_pytest/_py/path.py:219-222). On POSIX this code path is never reached.
Common situations: Running a test suite that worked on Linux/macOS on a Windows CI runner; asserting ownership in cross-platform tests; legacy py.path.local code that assumed Unix.
Related errors
- no {name!r} checker available for {self.path!r}
- can only pass None, Path instances or non-empty strings to L
- {relpath!r}: not a string or path object
- Don't know how to compute {hashtype!r} hash
- invalid specification {kw!r}
AI-assisted analysis of pytest-dev/pytest@0d6fbdeffa (2026-08-11).
Data as JSON: /api/errors/f7252532f07b0565.
Report an issue: GitHub.