summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_shutil.py17
-rw-r--r--Misc/NEWS.d/next/Tests/2020-03-16-20-54-55.bpo-26067.m18_VV.rst1
2 files changed, 12 insertions, 6 deletions
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
index 076c450..b9fdfd1 100644
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -1666,12 +1666,17 @@ class TestMisc(BaseTest, unittest.TestCase):
shutil.chown(dirname, group=gid)
check_chown(dirname, gid=gid)
- user = pwd.getpwuid(uid)[0]
- group = grp.getgrgid(gid)[0]
- shutil.chown(filename, user, group)
- check_chown(filename, uid, gid)
- shutil.chown(dirname, user, group)
- check_chown(dirname, uid, gid)
+ try:
+ user = pwd.getpwuid(uid)[0]
+ group = grp.getgrgid(gid)[0]
+ except KeyError:
+ # On some systems uid/gid cannot be resolved.
+ pass
+ else:
+ shutil.chown(filename, user, group)
+ check_chown(filename, uid, gid)
+ shutil.chown(dirname, user, group)
+ check_chown(dirname, uid, gid)
class TestWhich(BaseTest, unittest.TestCase):
diff --git a/Misc/NEWS.d/next/Tests/2020-03-16-20-54-55.bpo-26067.m18_VV.rst b/Misc/NEWS.d/next/Tests/2020-03-16-20-54-55.bpo-26067.m18_VV.rst
new file mode 100644
index 0000000..8b897a8
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2020-03-16-20-54-55.bpo-26067.m18_VV.rst
@@ -0,0 +1 @@
+Do not fail test_shutil test_chown test when uid or gid of user cannot be resolved to a name.