This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_resource fails if test has CAP_SYS_RESOURCE but isn't root
Type: Stage: resolved
Components: Tests Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: test_prlimit from test_resource fails when building python3 inside systemd-nspawn environment
View: 31132
Assigned To: Nosy List: benjamin.peterson, petr.viktorin
Priority: normal Keywords: patch

Created on 2018-09-13 20:31 by benjamin.peterson, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 9280 merged benjamin.peterson, 2018-09-13 20:33
Messages (2)
msg325293 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2018-09-13 20:31
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
msg325296 - (view) Author: Petr Viktorin (petr.viktorin) * (Python committer) Date: 2018-09-13 21:15
Check also discussion on issue31132.
If you agree, I'm OK with marking that one as duplicate, and removing the test.
History
Date User Action Args
2022-04-11 14:59:05adminsetgithub: 78849
2018-09-13 21:17:02petr.viktorinsetstatus: open -> closed
superseder: test_prlimit from test_resource fails when building python3 inside systemd-nspawn environment
resolution: duplicate
stage: patch review -> resolved
2018-09-13 21:15:28petr.viktorinsetnosy: + petr.viktorin
messages: + msg325296
2018-09-13 20:33:03benjamin.petersonsetkeywords: + patch
stage: patch review
pull_requests: + pull_request8711
2018-09-13 20:31:38benjamin.petersoncreate