| 1612 | # pathnames relative. |
| 1613 | # For details see bug #6054. |
| 1614 | def _test_pathname(self, path, cmp_path=None, dir=False): |
| 1615 | # Create a tarfile with an empty member named path |
| 1616 | # and compare the stored name with the original. |
| 1617 | foo = os.path.join(TEMPDIR, "foo") |
| 1618 | if not dir: |
| 1619 | os_helper.create_empty_file(foo) |
| 1620 | else: |
| 1621 | os.mkdir(foo) |
| 1622 | |
| 1623 | tar = tarfile.open(tmpname, self.mode) |
| 1624 | try: |
| 1625 | tar.add(foo, arcname=path) |
| 1626 | finally: |
| 1627 | tar.close() |
| 1628 | |
| 1629 | tar = tarfile.open(tmpname, "r") |
| 1630 | try: |
| 1631 | t = tar.next() |
| 1632 | finally: |
| 1633 | tar.close() |
| 1634 | |
| 1635 | if not dir: |
| 1636 | os_helper.unlink(foo) |
| 1637 | else: |
| 1638 | os_helper.rmdir(foo) |
| 1639 | |
| 1640 | self.assertEqual(t.name, cmp_path or path.replace(os.sep, "/")) |
| 1641 | |
| 1642 | |
| 1643 | @os_helper.skip_unless_symlink |