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_os: test_set_get_priority() fails when high niceness is set
Type: Stage:
Components: Tests Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Arfrever, giampaolo.rodola, neologix, r.david.murray
Priority: normal Keywords:

Created on 2011-02-27 21:20 by Arfrever, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (7)
msg129654 - (view) Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) * (Python triager) Date: 2011-02-27 21:20
$ nice -n20 python3.3 -m test.test_os
...
test_set_get_priority (__main__.ProgramPriorityTests) ... FAIL

======================================================================
FAIL: test_set_get_priority (__main__.ProgramPriorityTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python3.3/test/test_os.py", line 1280, in test_set_get_priority
    self.assertEqual(os.getpriority(os.PRIO_PROCESS, os.getpid()), base + 1)
AssertionError: 19 != 20
msg129655 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2011-02-27 21:27
Of course the test fails: a process can't have a nice value higher than a certain limit, which I think can vary depending on the UNIX variant in use. The fix is not to use "nice -n20".
msg129658 - (view) Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) * (Python triager) Date: 2011-02-27 21:39
I actually wanted to use 'nice -n19 python3.3 -m test.test_os', which also fails.
Test suite of Python can be run be a package manager, which automatically sets high niceness.
If niceness is high, then maybe this test could try to decrease it instead of increasing.
msg129684 - (view) Author: Charles-François Natali (neologix) * (Python committer) Date: 2011-02-28 07:39
> If niceness is high, then maybe this test could try to decrease it instead of increasing.

You must be root or have CAP_SYS_NICE to do that.
msg129702 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-02-28 13:26
We could, however, raise SkipTest if getpriority returns 19 or higher with a message like "unable to reliably test setpriority at current nice level of NN".  My guess is that no system we support has a lower upper limit on nice.  If someone wants to customize the test/message per OS, that would probably be even better; but not, I think, required.
msg129704 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-02-28 13:32
To be clear: raise SkipTest if prio is 19 or above *and* the increment fails.
msg129719 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2011-02-28 19:27
Committed in r88680.
History
Date User Action Args
2022-04-11 14:57:13adminsetgithub: 55557
2011-02-28 19:27:40giampaolo.rodolasetstatus: open -> closed

messages: + msg129719
resolution: fixed
nosy: giampaolo.rodola, Arfrever, r.david.murray, neologix
2011-02-28 13:32:59r.david.murraysetnosy: giampaolo.rodola, Arfrever, r.david.murray, neologix
messages: + msg129704
2011-02-28 13:26:56r.david.murraysetnosy: giampaolo.rodola, Arfrever, r.david.murray, neologix
messages: + msg129702
2011-02-28 07:39:15neologixsetnosy: + neologix
messages: + msg129684
2011-02-27 21:55:00r.david.murraysetnosy: + r.david.murray
2011-02-27 21:39:53Arfreversetnosy: giampaolo.rodola, Arfrever
messages: + msg129658
2011-02-27 21:27:22giampaolo.rodolasetnosy: giampaolo.rodola, Arfrever
messages: + msg129655
2011-02-27 21:20:21Arfrevercreate