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

Method test_make_zipfile_rootdir_nodir

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

Source from the content-addressed store, hash-verified

2109
2110 @support.requires_zlib()
2111 def test_make_zipfile_rootdir_nodir(self):
2112 # GH-99203: Test with root_dir is not a real directory.
2113 self.addCleanup(os_helper.unlink, f'{TESTFN}.zip')
2114 for dry_run in (False, True):
2115 with self.subTest(dry_run=dry_run):
2116 # root_dir does not exist.
2117 tmp_dir = self.mkdtemp()
2118 nonexisting_file = os.path.join(tmp_dir, 'nonexisting')
2119 with self.assertRaises(FileNotFoundError) as cm:
2120 make_archive(TESTFN, 'zip', nonexisting_file, dry_run=dry_run)
2121 self.assertEqual(cm.exception.errno, errno.ENOENT)
2122 self.assertEqual(cm.exception.filename, nonexisting_file)
2123 self.assertFalse(os.path.exists(f'{TESTFN}.zip'))
2124
2125 # root_dir is a file.
2126 tmp_fd, tmp_file = tempfile.mkstemp(dir=tmp_dir)
2127 os.close(tmp_fd)
2128 with self.assertRaises(NotADirectoryError) as cm:
2129 make_archive(TESTFN, 'zip', tmp_file, dry_run=dry_run)
2130 self.assertEqual(cm.exception.errno, errno.ENOTDIR)
2131 self.assertEqual(cm.exception.filename, tmp_file)
2132 self.assertFalse(os.path.exists(f'{TESTFN}.zip'))
2133
2134 ### shutil.unpack_archive
2135

Callers

nothing calls this directly

Calls 10

make_archiveFunction · 0.90
addCleanupMethod · 0.80
mkdtempMethod · 0.80
assertFalseMethod · 0.80
subTestMethod · 0.45
joinMethod · 0.45
assertRaisesMethod · 0.45
assertEqualMethod · 0.45
existsMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected