MCPcopy Index your code
hub / github.com/RustPython/RustPython / _test_pathname

Method _test_pathname

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

Source from the content-addressed store, hash-verified

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

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