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

Method test_make_zipfile_without_rootdir

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

Source from the content-addressed store, hash-verified

1811
1812 @support.requires_zlib()
1813 def test_make_zipfile_without_rootdir(self):
1814 root_dir, base_dir = self._create_files()
1815 # Test without base_dir.
1816 base_name = os.path.join(self.mkdtemp(), 'dst', 'archive')
1817 base_name = os.path.relpath(base_name, root_dir)
1818 with os_helper.change_cwd(root_dir), no_chdir:
1819 archive = make_archive(base_name, 'zip')
1820 self.assertEqual(archive, base_name + '.zip')
1821 self.assertTrue(os.path.isfile(archive))
1822 self.assertTrue(zipfile.is_zipfile(archive))
1823 with zipfile.ZipFile(archive) as zf:
1824 self.assertCountEqual(zf.namelist(),
1825 ['dist/', 'dist/sub/', 'dist/sub2/',
1826 'dist/file1', 'dist/file2', 'dist/sub/file3',
1827 'outer'])
1828
1829 # Test with base_dir.
1830 root_dir, base_dir = self._create_files()
1831 with os_helper.change_cwd(root_dir), no_chdir:
1832 base_name = os.path.join('dst', 'archive')
1833 archive = make_archive(base_name, 'zip', base_dir=base_dir)
1834 self.assertEqual(archive, base_name + '.zip')
1835 self.assertTrue(os.path.isfile(archive))
1836 self.assertTrue(zipfile.is_zipfile(archive))
1837 with zipfile.ZipFile(archive) as zf:
1838 self.assertCountEqual(zf.namelist(),
1839 ['dist/', 'dist/sub/', 'dist/sub2/',
1840 'dist/file1', 'dist/file2', 'dist/sub/file3'])
1841
1842 @support.requires_zlib()
1843 def test_make_zipfile_with_explicit_curdir(self):

Callers

nothing calls this directly

Calls 9

_create_filesMethod · 0.95
make_archiveFunction · 0.90
mkdtempMethod · 0.80
assertTrueMethod · 0.80
assertCountEqualMethod · 0.80
joinMethod · 0.45
assertEqualMethod · 0.45
isfileMethod · 0.45
namelistMethod · 0.45

Tested by

no test coverage detected