[Python-checkins] cpython: Fix test_spwd on OpenIndiana

victor.stinner python-checkins at python.org
Wed Mar 23 16:16:05 EDT 2016


https://hg.python.org/cpython/rev/c1677c8f92e1
changeset:   100707:c1677c8f92e1
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Wed Mar 23 21:15:55 2016 +0100
summary:
  Fix test_spwd on OpenIndiana

Issue #18787: restore "bin" name in test_spwd but catch KeyError.

files:
  Lib/test/test_spwd.py |  11 ++++++++---
  1 files changed, 8 insertions(+), 3 deletions(-)


diff --git a/Lib/test/test_spwd.py b/Lib/test/test_spwd.py
--- a/Lib/test/test_spwd.py
+++ b/Lib/test/test_spwd.py
@@ -61,9 +61,14 @@
 class TestSpwdNonRoot(unittest.TestCase):
 
     def test_getspnam_exception(self):
-        with self.assertRaises(PermissionError) as cm:
-            spwd.getspnam('root')
-        self.assertEqual(str(cm.exception), '[Errno 13] Permission denied')
+        name = 'bin'
+        try:
+            with self.assertRaises(PermissionError) as cm:
+                spwd.getspnam(name)
+        except KeyError as exc:
+            self.skipTest("spwd entry %r doesn't exist: %s" % (name, exc))
+        else:
+            self.assertEqual(str(cm.exception), '[Errno 13] Permission denied')
 
 
 if __name__ == "__main__":

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list