[Python-checkins] cpython: test_resource should not assume all attributes are available when they
brett.cannon
python-checkins at python.org
Fri Oct 25 21:45:48 CEST 2013
http://hg.python.org/cpython/rev/513da56d28de
changeset: 86635:513da56d28de
parent: 86632:f3d50720dee0
user: Brett Cannon <brett at python.org>
date: Fri Oct 25 15:45:25 2013 -0400
summary:
test_resource should not assume all attributes are available when they
are individually controlled by #ifdef statements in the extension
code.
files:
Lib/test/test_resource.py | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py
--- 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 @@
@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)
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list