Skip to content

Commit fb187f1

Browse files
committed
Add root user checks to test.support
This partially backports commit 86b8617 (GH-146195); making existing tests use the helper is omitted.
1 parent 363aec1 commit fb187f1

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎Lib/test/support/__init__.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@
7171
"BrokenIter",
7272
"in_systemd_nspawn_sync_suppressed",
7373
"run_no_yield_async_fn", "run_yielding_async_fn", "async_yield",
74-
"reset_code", "on_github_actions"
74+
"reset_code", "on_github_actions",
75+
"requires_root_user", "requires_non_root_user",
7576
]
7677

7778

@@ -3376,3 +3377,7 @@ def skip_on_low_desktop_heap_memory_subprocess(returncode):
33763377
if returncode == STATUS_DLL_INIT_FAILED:
33773378
raise unittest.SkipTest('gh-150436: DLL init failed, likely because '
33783379
'of low desktop heap memory')
3380+
3381+
_ROOT_IN_POSIX = hasattr(os, 'geteuid') and os.geteuid() == 0
3382+
requires_root_user = unittest.skipUnless(_ROOT_IN_POSIX, "test needs root privilege")
3383+
requires_non_root_user = unittest.skipIf(_ROOT_IN_POSIX, "test needs non-root account")

0 commit comments

Comments
 (0)