From 84d2ab9f33fafc715879eae951049e5771327d5d Mon Sep 17 00:00:00 2001 From: Dong-hee Na <donghee.na92@gmail.com> Date: Fri, 20 Mar 2020 01:12:34 +0900 Subject: [PATCH 1/5] bpo-40014: Skip adding os.getgrouplist info if error is raised --- Lib/test/pythoninfo.py | 10 +++++++--- .../Tests/2020-03-20-01-12-30.bpo-40014.h9SHIQ.rst | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 Misc/NEWS.d/next/Tests/2020-03-20-01-12-30.bpo-40014.h9SHIQ.rst diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py index cc230dd2297a0ba..e8694cfcc21a3aa 100644 --- a/Lib/test/pythoninfo.py +++ b/Lib/test/pythoninfo.py @@ -333,9 +333,13 @@ def collect_pwd(info_add): return if hasattr(os, 'getgrouplist'): - groups = os.getgrouplist(entry.pw_name, entry.pw_gid) - groups = ', '.join(map(str, groups)) - info_add('os.getgrouplist', groups) + try: + groups = os.getgrouplist(entry.pw_name, entry.pw_gid) + groups = ', '.join(map(str, groups)) + except OSError: + pass + else: + info_add('os.getgrouplist', groups) def collect_readline(info_add): diff --git a/Misc/NEWS.d/next/Tests/2020-03-20-01-12-30.bpo-40014.h9SHIQ.rst b/Misc/NEWS.d/next/Tests/2020-03-20-01-12-30.bpo-40014.h9SHIQ.rst new file mode 100644 index 000000000000000..1fd88c1facc00f3 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2020-03-20-01-12-30.bpo-40014.h9SHIQ.rst @@ -0,0 +1,2 @@ +Skip adding :func:`~os.getgrouplist` information during pythoninfo test. if +:exc:`OSError` is raised. Patch by Dong-hee Na. From 29ebba57801226584a56fc960a54def806d8f96b Mon Sep 17 00:00:00 2001 From: Dong-hee Na <donghee.na92@gmail.com> Date: Fri, 20 Mar 2020 01:36:49 +0900 Subject: [PATCH 2/5] bpo-40014: Update test_posix --- Lib/test/test_posix.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py index fad26d88be2f3f7..fdb946627214b44 100644 --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -1025,8 +1025,10 @@ def _create_and_do_getcwd(dirname, current_path_length = 0): def test_getgrouplist(self): user = pwd.getpwuid(os.getuid())[0] group = pwd.getpwuid(os.getuid())[3] - self.assertIn(group, posix.getgrouplist(user, group)) - + try: + self.assertIn(group, posix.getgrouplist(user, group)) + except OSError: + raise unittest.SkipTest("os.getgrouplist() is not available") @unittest.skipUnless(hasattr(os, 'getegid'), "test needs os.getegid()") def test_getgroups(self): From 2788493e69ad4d7df9a31b590246d8fb38a31601 Mon Sep 17 00:00:00 2001 From: Dong-hee Na <donghee.na92@gmail.com> Date: Fri, 20 Mar 2020 01:38:21 +0900 Subject: [PATCH 3/5] bpo-40014: Update NEWS.d --- .../next/Tests/2020-03-20-01-12-30.bpo-40014.h9SHIQ.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS.d/next/Tests/2020-03-20-01-12-30.bpo-40014.h9SHIQ.rst b/Misc/NEWS.d/next/Tests/2020-03-20-01-12-30.bpo-40014.h9SHIQ.rst index 1fd88c1facc00f3..56e7828140621a7 100644 --- a/Misc/NEWS.d/next/Tests/2020-03-20-01-12-30.bpo-40014.h9SHIQ.rst +++ b/Misc/NEWS.d/next/Tests/2020-03-20-01-12-30.bpo-40014.h9SHIQ.rst @@ -1,2 +1,2 @@ -Skip adding :func:`~os.getgrouplist` information during pythoninfo test. if -:exc:`OSError` is raised. Patch by Dong-hee Na. +Skip :func:`~os.getgrouplist` related tests. if :exc:`OSError` is raised. +Patch by Dong-hee Na. From cd8fc5523622ffa4d2664c5e9ab89b42f1da97bb Mon Sep 17 00:00:00 2001 From: Dong-hee Na <donghee.na92@gmail.com> Date: Fri, 20 Mar 2020 01:40:28 +0900 Subject: [PATCH 4/5] bpo-40014: Update NEWS.d --- Misc/NEWS.d/next/Tests/2020-03-20-01-12-30.bpo-40014.h9SHIQ.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Tests/2020-03-20-01-12-30.bpo-40014.h9SHIQ.rst b/Misc/NEWS.d/next/Tests/2020-03-20-01-12-30.bpo-40014.h9SHIQ.rst index 56e7828140621a7..572a2034cff68e0 100644 --- a/Misc/NEWS.d/next/Tests/2020-03-20-01-12-30.bpo-40014.h9SHIQ.rst +++ b/Misc/NEWS.d/next/Tests/2020-03-20-01-12-30.bpo-40014.h9SHIQ.rst @@ -1,2 +1,2 @@ -Skip :func:`~os.getgrouplist` related tests. if :exc:`OSError` is raised. +Skip :func:`~os.getgrouplist` related tests, if :exc:`OSError` is raised. Patch by Dong-hee Na. From ec921ea753a09698ff68585d1804b782ed1ac7d2 Mon Sep 17 00:00:00 2001 From: Dong-hee Na <donghee.na92@gmail.com> Date: Fri, 20 Mar 2020 07:32:02 +0900 Subject: [PATCH 5/5] bpo-40014: Apply Victors's code review. --- Lib/test/test_posix.py | 9 +++++++-- .../next/Tests/2020-03-20-01-12-30.bpo-40014.h9SHIQ.rst | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py index fdb946627214b44..f519504619b1100 100644 --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -1027,8 +1027,13 @@ def test_getgrouplist(self): group = pwd.getpwuid(os.getuid())[3] try: self.assertIn(group, posix.getgrouplist(user, group)) - except OSError: - raise unittest.SkipTest("os.getgrouplist() is not available") + except OSError as e: + # bpo-40014: getgrouplist fails with + # "[Errno 25] Inappropriate ioctl for device" on macOS + if sys.platform == 'darwin': + raise unittest.SkipTest("bpo-40014: os.getgrouplist() is not available") + else: + raise e @unittest.skipUnless(hasattr(os, 'getegid'), "test needs os.getegid()") def test_getgroups(self): diff --git a/Misc/NEWS.d/next/Tests/2020-03-20-01-12-30.bpo-40014.h9SHIQ.rst b/Misc/NEWS.d/next/Tests/2020-03-20-01-12-30.bpo-40014.h9SHIQ.rst index 572a2034cff68e0..477541c942fc47a 100644 --- a/Misc/NEWS.d/next/Tests/2020-03-20-01-12-30.bpo-40014.h9SHIQ.rst +++ b/Misc/NEWS.d/next/Tests/2020-03-20-01-12-30.bpo-40014.h9SHIQ.rst @@ -1,2 +1,2 @@ -Skip :func:`~os.getgrouplist` related tests, if :exc:`OSError` is raised. +test.pythoninfo: skip :func:`~os.getgrouplist` if it raises an :exc:`OSError`. Patch by Dong-hee Na.