diff options
| author | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-11 18:33:24 (GMT) |
|---|---|---|
| committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-11 18:33:24 (GMT) |
| commit | fd6e6cfa29b2289e711dc7f57f36897c78899ee7 (patch) | |
| tree | 8c4e153142c5cd0d123b2f53c0aee00223512ec2 /Lib/test/test_pwd.py | |
| parent | 64634eb32112c84b858ba58729e7c7246affad34 (diff) | |
| parent | 55e2238272daf0a6b585cf6314abb9fdf768bbde (diff) | |
| download | cpython-fd6e6cfa29b2289e711dc7f57f36897c78899ee7.zip cpython-fd6e6cfa29b2289e711dc7f57f36897c78899ee7.tar.gz cpython-fd6e6cfa29b2289e711dc7f57f36897c78899ee7.tar.bz2 | |
Raise KeyError instead of OverflowError when getpwuid's argument is out of
uid_t range.
Diffstat (limited to 'Lib/test/test_pwd.py')
| -rw-r--r-- | Lib/test/test_pwd.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_pwd.py b/Lib/test/test_pwd.py index ae1c8fe..aa8f69f 100644 --- a/Lib/test/test_pwd.py +++ b/Lib/test/test_pwd.py @@ -49,7 +49,9 @@ class PwdTest(unittest.TestCase): def test_errors(self): self.assertRaises(TypeError, pwd.getpwuid) + self.assertRaises(TypeError, pwd.getpwuid, 3.14) self.assertRaises(TypeError, pwd.getpwnam) + self.assertRaises(TypeError, pwd.getpwnam, 42) self.assertRaises(TypeError, pwd.getpwall, 42) # try to get some errors @@ -93,6 +95,13 @@ class PwdTest(unittest.TestCase): self.assertNotIn(fakeuid, byuids) self.assertRaises(KeyError, pwd.getpwuid, fakeuid) + # -1 shouldn't be a valid uid because it has a special meaning in many + # uid-related functions + self.assertRaises(KeyError, pwd.getpwuid, -1) + # should be out of uid_t range + self.assertRaises(KeyError, pwd.getpwuid, 2**128) + self.assertRaises(KeyError, pwd.getpwuid, -2**128) + def test_main(): support.run_unittest(PwdTest) |
