From 16685dc279650aee2f3af6cc812edf3e87160150 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 12 Jun 2021 12:10:34 -0300 Subject: [PATCH] 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 --- src/_pytest/tmpdir.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/_pytest/tmpdir.py b/src/_pytest/tmpdir.py index dcc37dc26..8c513ca46 100644 --- a/src/_pytest/tmpdir.py +++ b/src/_pytest/tmpdir.py @@ -1,6 +1,7 @@ """Support for providing temporary directories to test functions.""" import os import re +import sys import tempfile from pathlib import Path from typing import Optional @@ -130,9 +131,9 @@ class TempPathFactory: # Also, to keep things private, fixup any world-readable temp # rootdir's permissions. Historically 0o755 was used, so we can't # just error out on this, at least for a while. - if hasattr(os, "getuid"): - rootdir_stat = rootdir.stat() + if sys.platform != "win32": uid = os.getuid() + rootdir_stat = rootdir.stat() # getuid shouldn't fail, but cpython defines such a case. # Let's hope for the best. if uid != -1: