From b7bd5df809aabaf857eb51b139d5e519d8b3c364 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Tue, 22 Oct 2013 11:21:54 +0200 Subject: Issue #16595: Add prlimit() to resource module prlimit() is a Linux specific command that combines setrlimit, getrlimit and can set the limit of other processes. --- Lib/test/test_resource.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Lib/test/test_resource.py') diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py index 3c9c9a8292..950f4778be 100644 --- a/Lib/test/test_resource.py +++ b/Lib/test/test_resource.py @@ -139,6 +139,18 @@ class ResourceTest(unittest.TestCase): self.assertIsInstance(resource.RLIMIT_SIGPENDING, int) + @unittest.skipUnless(hasattr(resource, 'prlimit'), 'no prlimit') + def test_prlimit(self): + self.assertRaises(TypeError, resource.prlimit) + self.assertRaises(PermissionError, resource.prlimit, + 1, resource.RLIMIT_AS) + self.assertRaises(ProcessLookupError, resource.prlimit, + -1, resource.RLIMIT_AS) + self.assertEqual(resource.prlimit(0, resource.RLIMIT_AS), (-1, -1)) + self.assertEqual(resource.prlimit(0, resource.RLIMIT_AS, (-1, -1)), + (-1, -1)) + + def test_main(verbose=None): support.run_unittest(ResourceTest) -- cgit v1.2.1