mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
Issue #18787: spwd.getspnam() now raises a PermissionError if the user
doesn't have privileges.
This commit is contained in:
parent
af4a1f20ba
commit
3c3d7f4b99
5 changed files with 22 additions and 1 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue