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

Method test_tarfile_root_owner

Lib/test/test_shutil.py:1948–1967  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1946 @support.requires_zlib()
1947 @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
1948 def test_tarfile_root_owner(self):
1949 root_dir, base_dir = self._create_files()
1950 base_name = os.path.join(self.mkdtemp(), 'archive')
1951 group = grp.getgrgid(0)[0]
1952 owner = pwd.getpwuid(0)[0]
1953 with os_helper.change_cwd(root_dir), no_chdir:
1954 archive_name = make_archive(base_name, 'gztar', root_dir, 'dist',
1955 owner=owner, group=group)
1956
1957 # check if the compressed tarball was created
1958 self.assertTrue(os.path.isfile(archive_name))
1959
1960 # now checks the rights
1961 archive = tarfile.open(archive_name)
1962 try:
1963 for member in archive.getmembers():
1964 self.assertEqual(member.uid, 0)
1965 self.assertEqual(member.gid, 0)
1966 finally:
1967 archive.close()
1968
1969 def test_make_archive_cwd_default(self):
1970 current_dir = os.getcwd()

Callers

nothing calls this directly

Calls 10

_create_filesMethod · 0.95
make_archiveFunction · 0.90
mkdtempMethod · 0.80
assertTrueMethod · 0.80
getmembersMethod · 0.80
joinMethod · 0.45
isfileMethod · 0.45
openMethod · 0.45
assertEqualMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected