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

Function get_user_id

src/_pytest/compat.py:261–279  ·  view source on GitHub ↗

Return the current process's real user id or None if it could not be determined. :return: The user id or None if it could not be determined.

()

Source from the content-addressed store, hash-verified

259
260
261def get_user_id() -> int | None:
262 """Return the current process's real user id or None if it could not be
263 determined.
264
265 :return: The user id or None if it could not be determined.
266 """
267 # mypy follows the version and platform checking expectation of PEP 484:
268 # https://mypy.readthedocs.io/en/stable/common_issues.html?highlight=platform#python-version-and-system-platform-checks
269 # Containment checks are too complex for mypy v1.5.0 and cause failure.
270 if sys.platform == "win32" or sys.platform == "emscripten":
271 # win32 does not have a getuid() function.
272 # Emscripten has a return 0 stub.
273 return None
274 else:
275 # On other platforms, a return value of -1 is assumed to indicate that
276 # the current process's real user id could not be determined.
277 ERROR = -1
278 uid = os.getuid()
279 return uid if uid != ERROR else None
280
281
282if sys.version_info >= (3, 11):

Callers 1

getbasetempMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected