Skip to content

Commit 16685dc

Browse files
committed
Change os.getuid() guard in tmpdir.py
This matches the guard used by typeshed and avoid mypy errors on Windows: https://github.com/python/typeshed/blob/48a346920bbc24165bd9e9cf29a2b5140eae2abc/stdlib/os/__init__.pyi#L388
1 parent c85b21e commit 16685dc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/_pytest/tmpdir.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Support for providing temporary directories to test functions."""
22
import os
33
import re
4+
import sys
45
import tempfile
56
from pathlib import Path
67
from typing import Optional
@@ -130,9 +131,9 @@ def getbasetemp(self) -> Path:
130131
# Also, to keep things private, fixup any world-readable temp
131132
# rootdir's permissions. Historically 0o755 was used, so we can't
132133
# just error out on this, at least for a while.
133-
if hasattr(os, "getuid"):
134-
rootdir_stat = rootdir.stat()
134+
if sys.platform != "win32":
135135
uid = os.getuid()
136+
rootdir_stat = rootdir.stat()
136137
# getuid shouldn't fail, but cpython defines such a case.
137138
# Let's hope for the best.
138139
if uid != -1:

0 commit comments

Comments
 (0)