gh-117335: Handle non-iterables for ntpath.commonpath (GH-117336)

This commit is contained in:
Nice Zombies 2024-03-28 22:20:08 +01:00 committed by GitHub
parent 18cf239e39
commit 14f1ca7d53
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 7 deletions

View file

@ -871,11 +871,14 @@ class TestNtpath(NtpathTestCase):
self.assertRaises(exc, ntpath.commonpath,
[os.fsencode(p) for p in paths])
self.assertRaises(TypeError, ntpath.commonpath, None)
self.assertRaises(ValueError, ntpath.commonpath, [])
self.assertRaises(ValueError, ntpath.commonpath, iter([]))
check_error(ValueError, ['C:\\Program Files', 'Program Files'])
check_error(ValueError, ['C:\\Program Files', 'C:Program Files'])
check_error(ValueError, ['\\Program Files', 'Program Files'])
check_error(ValueError, ['Program Files', 'C:\\Program Files'])
check(['C:\\Program Files'], 'C:\\Program Files')
check(['C:\\Program Files', 'C:\\Program Files'], 'C:\\Program Files')
check(['C:\\Program Files\\', 'C:\\Program Files'],