Skip to content

Commit 730ff5b

Browse files
Extract realpath() tests to a separate PR.
1 parent de4fe01 commit 730ff5b

2 files changed

Lines changed: 0 additions & 60 deletions

File tree

Lib/test/test_ntpath.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -437,34 +437,6 @@ def test_realpath_strict(self):
437437
# gh-106242: Embedded nulls should raise OSError (not ValueError)
438438
self.assertRaises(OSError, ntpath.realpath, ABSTFN + "\0spam", strict=True)
439439

440-
@unittest.skipUnless(HAVE_GETFINALPATHNAME, 'need _getfinalpathname')
441-
def test_realpath_embedded_null(self):
442-
realpath = ntpath.realpath
443-
ABSTFN = ntpath.abspath(os_helper.TESTFN)
444-
path = ABSTFN + '\x00'
445-
self.assertEqual(realpath(path, strict=False), path)
446-
self.assertRaises(OSError, realpath, path, strict=True)
447-
path = os.fsencode(ABSTFN) + b'\x00'
448-
self.assertEqual(realpath(path, strict=False), path)
449-
self.assertRaises(OSError, realpath, path, strict=True)
450-
path = ABSTFN + '\\nonexistent\\x\x00'
451-
self.assertEqual(realpath(path, strict=False), path)
452-
self.assertRaises(OSError, realpath, path, strict=True)
453-
path = os.fsencode(ABSTFN) + b'\\nonexistent\\x\x00'
454-
self.assertEqual(realpath(path, strict=False), path)
455-
self.assertRaises(OSError, realpath, path, strict=True)
456-
457-
@unittest.skipUnless(HAVE_GETFINALPATHNAME, 'need _getfinalpathname')
458-
def test_realpath_undecodable(self):
459-
realpath = ntpath.realpath
460-
ABSTFN = ntpath.abspath(os_helper.TESTFN)
461-
path = os.fsencode(ABSTFN) + b'\xff'
462-
self.assertRaises(UnicodeDecodeError, realpath, path, strict=False)
463-
self.assertRaises(UnicodeDecodeError, realpath, path, strict=True)
464-
path = os.fsencode(ABSTFN) + b'\\nonexistent\\\xff'
465-
self.assertRaises(UnicodeDecodeError, realpath, path, strict=False)
466-
self.assertRaises(UnicodeDecodeError, realpath, path, strict=True)
467-
468440
@os_helper.skip_unless_symlink
469441
@unittest.skipUnless(HAVE_GETFINALPATHNAME, 'need _getfinalpathname')
470442
def test_realpath_relative(self):

Lib/test/test_posixpath.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -489,38 +489,6 @@ def test_realpath_strict(self):
489489
finally:
490490
os_helper.unlink(ABSTFN)
491491

492-
def test_realpath_embedded_null(self):
493-
path = '/\x00'
494-
self.assertRaises(ValueError, realpath, path, strict=False)
495-
self.assertRaises(ValueError, realpath, path, strict=True)
496-
path = b'/\x00'
497-
self.assertRaises(ValueError, realpath, path, strict=False)
498-
self.assertRaises(ValueError, realpath, path, strict=True)
499-
path = '/nonexistent/x\x00'
500-
self.assertRaises(ValueError, realpath, path, strict=False)
501-
self.assertRaises(FileNotFoundError, realpath, path, strict=True)
502-
path = b'/nonexistent/x\x00'
503-
self.assertRaises(ValueError, realpath, path, strict=False)
504-
self.assertRaises(FileNotFoundError, realpath, path, strict=True)
505-
506-
@unittest.skipIf(sys.platform == 'win32', 'requires native bytes paths')
507-
def test_realpath_unencodable(self):
508-
path = '/\ud800'
509-
self.assertRaises(UnicodeEncodeError, realpath, path, strict=False)
510-
self.assertRaises(UnicodeEncodeError, realpath, path, strict=True)
511-
path = '/nonexistent/\ud800'
512-
self.assertRaises(UnicodeEncodeError, realpath, path, strict=False)
513-
self.assertRaises(FileNotFoundError, realpath, path, strict=True)
514-
515-
@unittest.skipUnless(sys.platform == 'win32', 'requires native Unicode paths')
516-
def test_realpath_undecodable(self):
517-
path = b'/\xff'
518-
self.assertRaises(UnicodeDecodeError, realpath, path, strict=False)
519-
self.assertRaises(UnicodeDecodeError, realpath, path, strict=True)
520-
path = b'/nonexistent/\xff'
521-
self.assertRaises(UnicodeDecodeError, realpath, path, strict=False)
522-
self.assertRaises(FileNotFoundError, realpath, path, strict=True)
523-
524492
@os_helper.skip_unless_symlink
525493
@skip_if_ABSTFN_contains_backslash
526494
def test_realpath_relative(self):

0 commit comments

Comments
 (0)