Issue 34668: test_resource fails if test has CAP_SYS_RESOURCE but isn't root (original) (raw)
test_prlimit tries to test that raising the hardlimit of an unprivileged process. It tries to raise the hardlimit of pid 1, which usually raises a PermissionError. However, if the tests are privileged, this test can't work. The test tries to avoid this by only running the test if os.geteuid() != 0. However, there are other cases. For example, if the test process isn't root but has CAP_SYS_RESOURCE. While we could check for these other cases, I think we should just delete this test. There's no special logic in the prlimit implementation for handling permission errors, so it's not adding much value.
====================================================================== FAIL: test_prlimit (test.test_resource.ResourceTest)
Traceback (most recent call last): File "/buildbot/buildarea/3.x.ware-alpine/build/Lib/test/support/init.py", line 587, in wrapper return func(*args, **kw) File "/buildbot/buildarea/3.x.ware-alpine/build/Lib/test/test_resource.py", line 152, in test_prlimit 1, resource.RLIMIT_AS) AssertionError: PermissionError not raised by prlimit