summaryrefslogtreecommitdiff
path: root/Lib/test/test_resource.py
diff options
context:
space:
mode:
authorLarry Hastings <larry@hastings.org>2013-10-22 10:49:20 -0700
committerLarry Hastings <larry@hastings.org>2013-10-22 10:49:20 -0700
commitd0a7e678044dc86860cb362f153a2be5976200d9 (patch)
tree333e0926155d65c561418ce302c4a60d78156217 /Lib/test/test_resource.py
parente0d9a1c8bcaa0740b0a8d1e60070b947ab3463e7 (diff)
parent3f2f19230c8654461dfbcb68186babfb80d33ccc (diff)
downloadcpython-git-d0a7e678044dc86860cb362f153a2be5976200d9.tar.gz
Merge 3.4.0a4 release head back into trunk.
Diffstat (limited to 'Lib/test/test_resource.py')
-rw-r--r--Lib/test/test_resource.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py
index 1bf2a5a6ce..239d8d5e8d 100644
--- a/Lib/test/test_resource.py
+++ b/Lib/test/test_resource.py
@@ -1,3 +1,5 @@
+import sys
+import os
import unittest
from test import support
import time
@@ -129,6 +131,29 @@ class ResourceTest(unittest.TestCase):
self.assertIsInstance(pagesize, int)
self.assertGreaterEqual(pagesize, 0)
+ @unittest.skipUnless(sys.platform == 'linux', 'test requires Linux')
+ def test_linux_constants(self):
+ self.assertIsInstance(resource.RLIMIT_MSGQUEUE, int)
+ self.assertIsInstance(resource.RLIMIT_NICE, int)
+ self.assertIsInstance(resource.RLIMIT_RTPRIO, int)
+ self.assertIsInstance(resource.RLIMIT_RTTIME, int)
+ self.assertIsInstance(resource.RLIMIT_SIGPENDING, int)
+
+
+ @unittest.skipUnless(hasattr(resource, 'prlimit'), 'no prlimit')
+ def test_prlimit(self):
+ self.assertRaises(TypeError, resource.prlimit)
+ if os.geteuid() != 0:
+ self.assertRaises(PermissionError, resource.prlimit,
+ 1, resource.RLIMIT_AS)
+ self.assertRaises(ProcessLookupError, resource.prlimit,
+ -1, resource.RLIMIT_AS)
+ limit = resource.getrlimit(resource.RLIMIT_AS)
+ self.assertEqual(resource.prlimit(0, resource.RLIMIT_AS), limit)
+ self.assertEqual(resource.prlimit(0, resource.RLIMIT_AS, limit),
+ limit)
+
+
def test_main(verbose=None):
support.run_unittest(ResourceTest)