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