diff options
author | Malcolm Smith <smith@chaquo.com> | 2024-11-19 15:42:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-19 15:42:19 (GMT) |
commit | c5c9286804e38c95fe717f22ce1bf2f18eee5b17 (patch) | |
tree | 9348152398bcf83887696e82d57e5b4cb04fb8dd /Lib/test/test_posix.py | |
parent | 5fcc3a4cee76ab9bef4c2a76b0f5591cf576e2bf (diff) | |
download | cpython-c5c9286804e38c95fe717f22ce1bf2f18eee5b17.zip cpython-c5c9286804e38c95fe717f22ce1bf2f18eee5b17.tar.gz cpython-c5c9286804e38c95fe717f22ce1bf2f18eee5b17.tar.bz2 |
gh-118201: Simplify conv_confname (#126089)
Diffstat (limited to 'Lib/test/test_posix.py')
-rw-r--r-- | Lib/test/test_posix.py | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py index ef9d617..c9cbe15 100644 --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -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()') |