mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
gh-118201: Simplify conv_confname (#126089)
(cherry picked from commit c5c9286804
)
This commit is contained in:
parent
9a43485830
commit
e8e6e30054
6 changed files with 89 additions and 113 deletions
|
@ -568,10 +568,38 @@ class PosixTester(unittest.TestCase):
|
|||
|
||||
@unittest.skipUnless(hasattr(posix, 'confstr'),
|
||||
'test needs posix.confstr()')
|
||||
@unittest.skipIf(support.is_apple_mobile, "gh-118201: Test is flaky on iOS")
|
||||
def test_confstr(self):
|
||||
self.assertRaises(ValueError, posix.confstr, "CS_garbage")
|
||||
self.assertEqual(len(posix.confstr("CS_PATH")) > 0, True)
|
||||
with self.assertRaisesRegex(
|
||||
ValueError, "unrecognized configuration name"
|
||||
):
|
||||
posix.confstr("CS_garbage")
|
||||
|
||||
with self.assertRaisesRegex(
|
||||
TypeError, "configuration names must be strings or integers"
|
||||
):
|
||||
posix.confstr(1.23)
|
||||
|
||||
path = posix.confstr("CS_PATH")
|
||||
self.assertGreater(len(path), 0)
|
||||
self.assertEqual(posix.confstr(posix.confstr_names["CS_PATH"]), path)
|
||||
|
||||
@unittest.skipUnless(hasattr(posix, 'sysconf'),
|
||||
'test needs posix.sysconf()')
|
||||
def test_sysconf(self):
|
||||
with self.assertRaisesRegex(
|
||||
ValueError, "unrecognized configuration name"
|
||||
):
|
||||
posix.sysconf("SC_garbage")
|
||||
|
||||
with self.assertRaisesRegex(
|
||||
TypeError, "configuration names must be strings or integers"
|
||||
):
|
||||
posix.sysconf(1.23)
|
||||
|
||||
arg_max = posix.sysconf("SC_ARG_MAX")
|
||||
self.assertGreater(arg_max, 0)
|
||||
self.assertEqual(
|
||||
posix.sysconf(posix.sysconf_names["SC_ARG_MAX"]), arg_max)
|
||||
|
||||
@unittest.skipUnless(hasattr(posix, 'dup2'),
|
||||
'test needs posix.dup2()')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue