summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGiampaolo RodolĂ  <g.rodola@gmail.com>2011-02-25 20:57:54 (GMT)
committerGiampaolo RodolĂ  <g.rodola@gmail.com>2011-02-25 20:57:54 (GMT)
commit18e8bcb289dd5ea77c12668ea1e2904627fc8531 (patch)
tree2913219ca3d5ff58b4f9dbb767f1ccba36c7b1f0 /Lib
parent211b81dd0916ce6e83f23b222bc06d45b904a838 (diff)
downloadcpython-18e8bcb289dd5ea77c12668ea1e2904627fc8531.zip
cpython-18e8bcb289dd5ea77c12668ea1e2904627fc8531.tar.gz
cpython-18e8bcb289dd5ea77c12668ea1e2904627fc8531.tar.bz2
Issue 10784: adds os.getpriority() and os.setpriority() functions.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_os.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 4965786..29b6b9a 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -1268,6 +1268,24 @@ class LoginTests(unittest.TestCase):
self.assertNotEqual(len(user_name), 0)
+@unittest.skipUnless(hasattr(os, 'getpriority') and hasattr(os, 'setpriority'),
+ "needs os.getpriority and os.setpriority")
+class ProgramPriorityTests(unittest.TestCase):
+ """Tests for os.getpriority() and os.setpriority()."""
+
+ def test_set_get_priority(self):
+ base = os.getpriority(os.PRIO_PROCESS, os.getpid())
+ os.setpriority(os.PRIO_PROCESS, os.getpid(), base + 1)
+ try:
+ self.assertEqual(os.getpriority(os.PRIO_PROCESS, os.getpid()), base + 1)
+ finally:
+ try:
+ os.setpriority(os.PRIO_PROCESS, os.getpid(), base)
+ except OSError as err:
+ if err.errno != EACCESS:
+ raise
+
+
class SendfileTestServer(asyncore.dispatcher, threading.Thread):
class Handler(asynchat.async_chat):
@@ -1535,6 +1553,7 @@ def test_main():
LoginTests,
LinkTests,
TestSendfile,
+ ProgramPriorityTests,
)
if __name__ == "__main__":