mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
gh-108303: Move zip and tar archives to Lib/test/archivetestdata (#111549)
This commit is contained in:
parent
18c954849b
commit
890ef1b035
14 changed files with 24 additions and 23 deletions
|
|
@ -43,7 +43,7 @@ def sha256sum(data):
|
|||
|
||||
TEMPDIR = os.path.abspath(os_helper.TESTFN) + "-tardir"
|
||||
tarextdir = TEMPDIR + '-extract-test'
|
||||
tarname = support.findfile("testtar.tar")
|
||||
tarname = support.findfile("testtar.tar", subdir="archivetestdata")
|
||||
gzipname = os.path.join(TEMPDIR, "testtar.tar.gz")
|
||||
bz2name = os.path.join(TEMPDIR, "testtar.tar.bz2")
|
||||
xzname = os.path.join(TEMPDIR, "testtar.tar.xz")
|
||||
|
|
@ -491,7 +491,7 @@ class CommonReadTest(ReadTest):
|
|||
# bpo-39017 (CVE-2019-20907): reading a zero-length header should fail
|
||||
# with an exception
|
||||
with self.assertRaisesRegex(tarfile.ReadError, "file could not be opened successfully"):
|
||||
with tarfile.open(support.findfile('recursion.tar')) as tar:
|
||||
with tarfile.open(support.findfile('recursion.tar', subdir='archivetestdata')):
|
||||
pass
|
||||
|
||||
def test_extractfile_name(self):
|
||||
|
|
@ -2565,7 +2565,7 @@ class MiscTest(unittest.TestCase):
|
|||
support.check__all__(self, tarfile, not_exported=not_exported)
|
||||
|
||||
def test_useful_error_message_when_modules_missing(self):
|
||||
fname = os.path.join(os.path.dirname(__file__), 'testtar.tar.xz')
|
||||
fname = os.path.join(os.path.dirname(__file__), 'archivetestdata', 'testtar.tar.xz')
|
||||
with self.assertRaises(tarfile.ReadError) as excinfo:
|
||||
error = tarfile.CompressionError('lzma module is not available'),
|
||||
with unittest.mock.patch.object(tarfile.TarFile, 'xzopen', side_effect=error):
|
||||
|
|
@ -2630,7 +2630,7 @@ class CommandLineTest(unittest.TestCase):
|
|||
self.assertIn(b'is a tar archive.\n', out)
|
||||
|
||||
def test_test_command_invalid_file(self):
|
||||
zipname = support.findfile('zipdir.zip')
|
||||
zipname = support.findfile('zipdir.zip', subdir='archivetestdata')
|
||||
rc, out, err = self.tarfilecmd_failure('-t', zipname)
|
||||
self.assertIn(b' is not a tar archive.', err)
|
||||
self.assertEqual(out, b'')
|
||||
|
|
@ -2672,7 +2672,7 @@ class CommandLineTest(unittest.TestCase):
|
|||
self.assertEqual(out, expected)
|
||||
|
||||
def test_list_command_invalid_file(self):
|
||||
zipname = support.findfile('zipdir.zip')
|
||||
zipname = support.findfile('zipdir.zip', subdir='archivetestdata')
|
||||
rc, out, err = self.tarfilecmd_failure('-l', zipname)
|
||||
self.assertIn(b' is not a tar archive.', err)
|
||||
self.assertEqual(out, b'')
|
||||
|
|
@ -2797,7 +2797,7 @@ class CommandLineTest(unittest.TestCase):
|
|||
os_helper.rmtree(tarextdir)
|
||||
|
||||
def test_extract_command_invalid_file(self):
|
||||
zipname = support.findfile('zipdir.zip')
|
||||
zipname = support.findfile('zipdir.zip', subdir='archivetestdata')
|
||||
with os_helper.temp_cwd(tarextdir):
|
||||
rc, out, err = self.tarfilecmd_failure('-e', zipname)
|
||||
self.assertIn(b' is not a tar archive.', err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue