Skip to content

Commit 8da0b0a

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 f691177 commit 8da0b0a

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎Lib/test/support/__init__.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"force_not_colorized_test_class",
6767
"make_clean_env",
6868
"BrokenIter",
69+
"requires_root_user", "requires_non_root_user",
6970
]
7071

7172

@@ -2921,3 +2922,7 @@ def skip_on_low_desktop_heap_memory_subprocess(returncode):
29212922
if returncode == STATUS_DLL_INIT_FAILED:
29222923
raise unittest.SkipTest('gh-150436: DLL init failed, likely because '
29232924
'of low desktop heap memory')
2925+
2926+
_ROOT_IN_POSIX = hasattr(os, 'geteuid') and os.geteuid() == 0
2927+
requires_root_user = unittest.skipUnless(_ROOT_IN_POSIX, "test needs root privilege")
2928+
requires_non_root_user = unittest.skipIf(_ROOT_IN_POSIX, "test needs non-root account")

0 commit comments

Comments
 (0)