MCPcopy Index your code
hub / github.com/python/cpython / _test_pathname

Method _test_pathname

Lib/test/test_tarfile.py:1631–1657  ·  view source on GitHub ↗
(self, path, cmp_path=None, dir=False)

Source from the content-addressed store, hash-verified

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

Callers 2

test_pathnamesMethod · 0.95
test_abs_pathnamesMethod · 0.95

Calls 10

rmdirMethod · 0.80
joinMethod · 0.45
mkdirMethod · 0.45
openMethod · 0.45
addMethod · 0.45
closeMethod · 0.45
nextMethod · 0.45
unlinkMethod · 0.45
assertEqualMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected