MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_realpath_basic

Method test_realpath_basic

Lib/test/test_ntpath.py:544–568  ·  view source on GitHub ↗
(self, kwargs)

Source from the content-addressed store, hash-verified

542 @unittest.skipUnless(HAVE_GETFINALPATHNAME, 'need _getfinalpathname')
543 @_parameterize({}, {'strict': True}, {'strict': ALLOW_MISSING})
544 def test_realpath_basic(self, kwargs):
545 ABSTFN = ntpath.abspath(os_helper.TESTFN)
546 open(ABSTFN, "wb").close()
547 self.addCleanup(os_helper.unlink, ABSTFN)
548 self.addCleanup(os_helper.unlink, ABSTFN + "1")
549
550 os.symlink(ABSTFN, ABSTFN + "1")
551 self.assertPathEqual(ntpath.realpath(ABSTFN + "1", **kwargs), ABSTFN)
552 self.assertPathEqual(ntpath.realpath(os.fsencode(ABSTFN + "1"), **kwargs),
553 os.fsencode(ABSTFN))
554
555 # gh-88013: call ntpath.realpath with binary drive name may raise a
556 # TypeError. The drive should not exist to reproduce the bug.
557 drives = {f"{c}:\\" for c in string.ascii_uppercase} - set(os.listdrives())
558 d = drives.pop().encode()
559 self.assertEqual(ntpath.realpath(d, strict=False), d)
560
561 # gh-106242: Embedded nulls and non-strict fallback to abspath
562 if kwargs:
563 with self.assertRaises(OSError):
564 ntpath.realpath(os_helper.TESTFN + "\0spam",
565 **kwargs)
566 else:
567 self.assertEqual(ABSTFN + "\0spam",
568 ntpath.realpath(os_helper.TESTFN + "\0spam", **kwargs))
569
570 @os_helper.skip_unless_symlink
571 @unittest.skipUnless(HAVE_GETFINALPATHNAME, 'need _getfinalpathname')

Callers

nothing calls this directly

Calls 11

setFunction · 0.85
addCleanupMethod · 0.80
realpathMethod · 0.80
fsencodeMethod · 0.80
openFunction · 0.50
closeMethod · 0.45
assertPathEqualMethod · 0.45
encodeMethod · 0.45
popMethod · 0.45
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected