summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_resource.py
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2013-10-25 19:45:25 (GMT)
committerBrett Cannon <brett@python.org>2013-10-25 19:45:25 (GMT)
commita20800d1d93bf83c131523f14271a34641f1f588 (patch)
tree968a65ed9eb982bb1cc9c201fa69925e6033b5b2 /Lib/test/test_resource.py
parente38b0544c4f89fe3e665721e52c027e006922032 (diff)
downloadcpython-a20800d1d93bf83c131523f14271a34641f1f588.zip
cpython-a20800d1d93bf83c131523f14271a34641f1f588.tar.gz
cpython-a20800d1d93bf83c131523f14271a34641f1f588.tar.bz2
test_resource should not assume all attributes are available when they
are individually controlled by #ifdef statements in the extension code.
Diffstat (limited to 'Lib/test/test_resource.py')
-rw-r--r--Lib/test/test_resource.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py
index 2184655..006198f 100644
--- a/Lib/test/test_resource.py
+++ b/Lib/test/test_resource.py
@@ -1,3 +1,4 @@
+import contextlib
import sys
import os
import unittest
@@ -133,12 +134,9 @@ class ResourceTest(unittest.TestCase):
@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)
-
+ for attr in ['MSGQUEUE', 'NICE', 'RTPRIO', 'RTTIME', 'SIGPENDING']:
+ with contextlib.suppress(AttributeError):
+ self.assertIsInstance(getattr(resource, 'RLIMIT_' + attr), int)
@unittest.skipUnless(hasattr(resource, 'prlimit'), 'no prlimit')
@support.requires_linux_version(2, 6, 36)