Issue #18787: spwd.getspnam() now raises a PermissionError if the user

doesn't have privileges.
This commit is contained in:
Berker Peksag 2016-03-19 11:44:17 +02:00
parent af4a1f20ba
commit 3c3d7f4b99
5 changed files with 22 additions and 1 deletions

View file

@ -56,5 +56,15 @@ class TestSpwdRoot(unittest.TestCase):
self.assertRaises(TypeError, spwd.getspnam, bytes_name)
@unittest.skipUnless(hasattr(os, 'geteuid') and os.geteuid() != 0,
'non-root user required')
class TestSpwdNonRoot(unittest.TestCase):
def test_getspnam_exception(self):
with self.assertRaises(PermissionError) as cm:
spwd.getspnam('bin')
self.assertEqual(str(cm.exception), '[Errno 13] Permission denied')
if __name__ == "__main__":
unittest.main()