| 1629 | # pathnames relative. |
| 1630 | # For details see bug #6054. |
| 1631 | def _test_pathname(self, path, cmp_path=None, dir=False): |
| 1632 | # Create a tarfile with an empty member named path |
| 1633 | # and compare the stored name with the original. |
| 1634 | foo = os.path.join(TEMPDIR, "foo") |
| 1635 | if not dir: |
| 1636 | os_helper.create_empty_file(foo) |
| 1637 | else: |
| 1638 | os.mkdir(foo) |
| 1639 | |
| 1640 | tar = tarfile.open(tmpname, self.mode) |
| 1641 | try: |
| 1642 | tar.add(foo, arcname=path) |
| 1643 | finally: |
| 1644 | tar.close() |
| 1645 | |
| 1646 | tar = tarfile.open(tmpname, "r") |
| 1647 | try: |
| 1648 | t = tar.next() |
| 1649 | finally: |
| 1650 | tar.close() |
| 1651 | |
| 1652 | if not dir: |
| 1653 | os_helper.unlink(foo) |
| 1654 | else: |
| 1655 | os_helper.rmdir(foo) |
| 1656 | |
| 1657 | self.assertEqual(t.name, cmp_path or path.replace(os.sep, "/")) |
| 1658 | |
| 1659 | |
| 1660 | @os_helper.skip_unless_symlink |