(self, kwargs)
| 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') |
nothing calls this directly
no test coverage detected