From: Christian Heimes Date: Tue, 22 Oct 2013 09:45:30 +0000 (+0200) Subject: Make resource tests more robust. X-Git-Tag: v3.4.0b1~571^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d885aa4d662d6b5aae33f6ecfbaccde3f201ad39;p=python Make resource tests more robust. --- diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py index 950f4778be..239d8d5e8d 100644 --- a/Lib/test/test_resource.py +++ b/Lib/test/test_resource.py @@ -1,4 +1,5 @@ import sys +import os import unittest from test import support import time @@ -142,13 +143,15 @@ class ResourceTest(unittest.TestCase): @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) + if os.geteuid() != 0: + 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)) + 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):