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

Method test_make_tarfile_rootdir_nodir

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

Source from the content-addressed store, hash-verified

2085 self.assertNotIn('xxx', formats)
2086
2087 def test_make_tarfile_rootdir_nodir(self):
2088 # GH-99203: Test with root_dir is not a real directory.
2089 self.addCleanup(os_helper.unlink, f'{TESTFN}.tar')
2090 for dry_run in (False, True):
2091 with self.subTest(dry_run=dry_run):
2092 # root_dir does not exist.
2093 tmp_dir = self.mkdtemp()
2094 nonexisting_file = os.path.join(tmp_dir, 'nonexisting')
2095 with self.assertRaises(FileNotFoundError) as cm:
2096 make_archive(TESTFN, 'tar', nonexisting_file, dry_run=dry_run)
2097 self.assertEqual(cm.exception.errno, errno.ENOENT)
2098 self.assertEqual(cm.exception.filename, nonexisting_file)
2099 self.assertFalse(os.path.exists(f'{TESTFN}.tar'))
2100
2101 # root_dir is a file.
2102 tmp_fd, tmp_file = tempfile.mkstemp(dir=tmp_dir)
2103 os.close(tmp_fd)
2104 with self.assertRaises(NotADirectoryError) as cm:
2105 make_archive(TESTFN, 'tar', tmp_file, dry_run=dry_run)
2106 self.assertEqual(cm.exception.errno, errno.ENOTDIR)
2107 self.assertEqual(cm.exception.filename, tmp_file)
2108 self.assertFalse(os.path.exists(f'{TESTFN}.tar'))
2109
2110 @support.requires_zlib()
2111 def test_make_zipfile_rootdir_nodir(self):

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