diff options
author | Christian Heimes <christian@cheimes.de> | 2013-10-22 09:45:30 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2013-10-22 09:45:30 (GMT) |
commit | d885aa4d662d6b5aae33f6ecfbaccde3f201ad39 (patch) | |
tree | 9c99864d63c7433f4f72075b205963cb03759995 /Lib/test/test_resource.py | |
parent | b7bd5df809aabaf857eb51b139d5e519d8b3c364 (diff) | |
download | cpython-d885aa4d662d6b5aae33f6ecfbaccde3f201ad39.zip cpython-d885aa4d662d6b5aae33f6ecfbaccde3f201ad39.tar.gz cpython-d885aa4d662d6b5aae33f6ecfbaccde3f201ad39.tar.bz2 |
Make resource tests more robust.
Diffstat (limited to 'Lib/test/test_resource.py')
-rw-r--r-- | Lib/test/test_resource.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py index 950f477..239d8d5 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): |