]> granicus.if.org Git - python/commitdiff
Fix test_spwd on OpenIndiana
authorVictor Stinner <victor.stinner@gmail.com>
Wed, 23 Mar 2016 20:15:55 +0000 (21:15 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Wed, 23 Mar 2016 20:15:55 +0000 (21:15 +0100)
Issue #18787: restore "bin" name in test_spwd but catch KeyError.

Lib/test/test_spwd.py

index 3a11a2d1d622a9ae30ce8ba059da55f8cb0ff3b2..e893f3a847fdf9032ca908f73a5c80adea0c045e 100644 (file)
@@ -61,9 +61,14 @@ class TestSpwdRoot(unittest.TestCase):
 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__":