From d885aa4d662d6b5aae33f6ecfbaccde3f201ad39 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Tue, 22 Oct 2013 11:45:30 +0200 Subject: [PATCH] Make resource tests more robust. --- Lib/test/test_resource.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py index 950f4778be4..239d8d5e8d8 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):