mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
test_resource should not assume all attributes are available when they
are individually controlled by #ifdef statements in the extension code.
This commit is contained in:
parent
e38b0544c4
commit
a20800d1d9
1 changed files with 4 additions and 6 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import contextlib
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
|
@ -133,12 +134,9 @@ class ResourceTest(unittest.TestCase):
|
||||||
|
|
||||||
@unittest.skipUnless(sys.platform == 'linux', 'test requires Linux')
|
@unittest.skipUnless(sys.platform == 'linux', 'test requires Linux')
|
||||||
def test_linux_constants(self):
|
def test_linux_constants(self):
|
||||||
self.assertIsInstance(resource.RLIMIT_MSGQUEUE, int)
|
for attr in ['MSGQUEUE', 'NICE', 'RTPRIO', 'RTTIME', 'SIGPENDING']:
|
||||||
self.assertIsInstance(resource.RLIMIT_NICE, int)
|
with contextlib.suppress(AttributeError):
|
||||||
self.assertIsInstance(resource.RLIMIT_RTPRIO, int)
|
self.assertIsInstance(getattr(resource, 'RLIMIT_' + attr), int)
|
||||||
self.assertIsInstance(resource.RLIMIT_RTTIME, int)
|
|
||||||
self.assertIsInstance(resource.RLIMIT_SIGPENDING, int)
|
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipUnless(hasattr(resource, 'prlimit'), 'no prlimit')
|
@unittest.skipUnless(hasattr(resource, 'prlimit'), 'no prlimit')
|
||||||
@support.requires_linux_version(2, 6, 36)
|
@support.requires_linux_version(2, 6, 36)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue