Skip to content

Commit 440d8ea

Browse files
committed
Handle more possible Exceptions explicitly.
1 parent 3db7bf2 commit 440d8ea

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

Lib/test/test_posixpath.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -506,13 +506,13 @@ def test_realpath_invalid_paths(self):
506506
self.assertRaises(ValueError, realpath, path, strict=ALLOW_MISSING)
507507
path = '/nonexistent/x\x00'
508508
self.assertRaises(ValueError, realpath, path, strict=False)
509-
self.assertRaises(FileNotFoundError, realpath, path, strict=ALL_BUT_LAST)
510-
self.assertRaises(FileNotFoundError, realpath, path, strict=True)
509+
self.assertRaises((FileNotFoundError, ValueError), realpath, path, strict=ALL_BUT_LAST)
510+
self.assertRaises((FileNotFoundError, ValueError), realpath, path, strict=True)
511511
self.assertRaises(ValueError, realpath, path, strict=ALLOW_MISSING)
512512
path = b'/nonexistent/x\x00'
513513
self.assertRaises(ValueError, realpath, path, strict=False)
514-
self.assertRaises(FileNotFoundError, realpath, path, strict=ALL_BUT_LAST)
515-
self.assertRaises(FileNotFoundError, realpath, path, strict=True)
514+
self.assertRaises((FileNotFoundError, ValueError), realpath, path, strict=ALL_BUT_LAST)
515+
self.assertRaises((FileNotFoundError, ValueError), realpath, path, strict=True)
516516
self.assertRaises(ValueError, realpath, path, strict=ALLOW_MISSING)
517517
path = '/\x00/..'
518518
self.assertRaises(ValueError, realpath, path, strict=False)
@@ -527,13 +527,13 @@ def test_realpath_invalid_paths(self):
527527

528528
path = '/nonexistent/x\x00/..'
529529
self.assertRaises(ValueError, realpath, path, strict=False)
530-
self.assertRaises(FileNotFoundError, realpath, path, strict=ALL_BUT_LAST)
531-
self.assertRaises(FileNotFoundError, realpath, path, strict=True)
530+
self.assertRaises((FileNotFoundError, ValueError), realpath, path, strict=ALL_BUT_LAST)
531+
self.assertRaises((FileNotFoundError, ValueError), realpath, path, strict=True)
532532
self.assertRaises(ValueError, realpath, path, strict=ALLOW_MISSING)
533533
path = b'/nonexistent/x\x00/..'
534534
self.assertRaises(ValueError, realpath, path, strict=False)
535-
self.assertRaises(FileNotFoundError, realpath, path, strict=ALL_BUT_LAST)
536-
self.assertRaises(FileNotFoundError, realpath, path, strict=True)
535+
self.assertRaises((FileNotFoundError, ValueError), realpath, path, strict=ALL_BUT_LAST)
536+
self.assertRaises((FileNotFoundError, ValueError), realpath, path, strict=True)
537537
self.assertRaises(ValueError, realpath, path, strict=ALLOW_MISSING)
538538

539539
path = '/\udfff'
@@ -553,8 +553,8 @@ def test_realpath_invalid_paths(self):
553553
else:
554554
self.assertRaises(UnicodeEncodeError, realpath, path, strict=False)
555555
self.assertRaises(UnicodeEncodeError, realpath, path, strict=ALLOW_MISSING)
556-
self.assertRaises(FileNotFoundError, realpath, path, strict=ALL_BUT_LAST)
557-
self.assertRaises(FileNotFoundError, realpath, path, strict=True)
556+
self.assertRaises((FileNotFoundError, ValueError), realpath, path, strict=ALL_BUT_LAST)
557+
self.assertRaises((FileNotFoundError, ValueError), realpath, path, strict=True)
558558
path = '/\udfff/..'
559559
if sys.platform == 'win32':
560560
self.assertEqual(realpath(path, strict=False), '/')
@@ -572,8 +572,8 @@ def test_realpath_invalid_paths(self):
572572
else:
573573
self.assertRaises(UnicodeEncodeError, realpath, path, strict=False)
574574
self.assertRaises(UnicodeEncodeError, realpath, path, strict=ALLOW_MISSING)
575-
self.assertRaises(FileNotFoundError, realpath, path, strict=ALL_BUT_LAST)
576-
self.assertRaises(FileNotFoundError, realpath, path, strict=True)
575+
self.assertRaises((FileNotFoundError, ValueError), realpath, path, strict=ALL_BUT_LAST)
576+
self.assertRaises((FileNotFoundError, ValueError), realpath, path, strict=True)
577577

578578
path = b'/\xff'
579579
if sys.platform == 'win32':

0 commit comments

Comments
 (0)