Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-108303: Move zip and tar archives to Lib/test/archivetestdata #111549

Merged
merged 4 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion Lib/test/test_contextlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@ def test_simple(self):
def test_reentrant(self):
old_cwd = os.getcwd()
target1 = self.make_relative_path('data')
target2 = self.make_relative_path('ziptestdata')
target2 = self.make_relative_path('archivetestdata')
self.assertNotIn(old_cwd, (target1, target2))
chdir1, chdir2 = chdir(target1), chdir(target2)

Expand Down
12 changes: 6 additions & 6 deletions Lib/test/test_tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -491,7 +491,7 @@ def test_length_zero_header(self):
# 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):
Expand Down Expand Up @@ -2565,7 +2565,7 @@ def test__all__(self):
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):
Expand Down Expand Up @@ -2630,7 +2630,7 @@ def test_test_command_verbose(self):
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'')
Expand Down Expand Up @@ -2672,7 +2672,7 @@ def test_list_command_verbose(self):
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'')
Expand Down Expand Up @@ -2797,7 +2797,7 @@ def test_extract_command_different_directory(self):
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)
Expand Down
14 changes: 7 additions & 7 deletions Lib/test/test_zipfile/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1754,7 +1754,7 @@ def test_unsupported_version(self):
@requires_zlib()
def test_read_unicode_filenames(self):
# bug #10801
fname = findfile('zip_cp437_header.zip')
fname = findfile('zip_cp437_header.zip', subdir='archivetestdata')
with zipfile.ZipFile(fname) as zipfp:
for name in zipfp.namelist():
zipfp.open(name).close()
Expand Down Expand Up @@ -2804,7 +2804,7 @@ def setUp(self):
os.mkdir(TESTFN2)

def test_extract_dir(self):
with zipfile.ZipFile(findfile("zipdir.zip")) as zipf:
with zipfile.ZipFile(findfile("zipdir.zip", subdir="archivetestdata")) as zipf:
zipf.extractall(TESTFN2)
self.assertTrue(os.path.isdir(os.path.join(TESTFN2, "a")))
self.assertTrue(os.path.isdir(os.path.join(TESTFN2, "a", "b")))
Expand Down Expand Up @@ -2973,7 +2973,7 @@ def test_bad_use(self):
self.assertNotEqual(err.strip(), b'')

def test_test_command(self):
zip_name = findfile('zipdir.zip')
zip_name = findfile('zipdir.zip', subdir='archivetestdata')
for opt in '-t', '--test':
out = self.zipfilecmd(opt, zip_name)
self.assertEqual(out.rstrip(), b'Done testing')
Expand All @@ -2982,7 +2982,7 @@ def test_test_command(self):
self.assertEqual(out, b'')

def test_list_command(self):
zip_name = findfile('zipdir.zip')
zip_name = findfile('zipdir.zip', subdir='archivetestdata')
t = io.StringIO()
with zipfile.ZipFile(zip_name, 'r') as tf:
tf.printdir(t)
Expand Down Expand Up @@ -3015,7 +3015,7 @@ def test_create_command(self):
unlink(TESTFN2)

def test_extract_command(self):
zip_name = findfile('zipdir.zip')
zip_name = findfile('zipdir.zip', subdir='archivetestdata')
for opt in '-e', '--extract':
with temp_dir() as extdir:
out = self.zipfilecmd(opt, zip_name, extdir)
Expand All @@ -3036,8 +3036,8 @@ class TestExecutablePrependedZip(unittest.TestCase):
"""Test our ability to open zip files with an executable prepended."""

def setUp(self):
self.exe_zip = findfile('exe_with_zip', subdir='ziptestdata')
self.exe_zip64 = findfile('exe_with_z64', subdir='ziptestdata')
self.exe_zip = findfile('exe_with_zip', subdir='archivetestdata')
self.exe_zip64 = findfile('exe_with_z64', subdir='archivetestdata')

def _test_zip_works(self, name):
# bpo28494 sanity check: ensure is_zipfile works on these.
Expand Down
4 changes: 2 additions & 2 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -2176,6 +2176,7 @@ LIBSUBDIRS= asyncio \
TESTSUBDIRS= idlelib/idle_test \
test \
test/audiodata \
test/archivetestdata \
test/certdata \
test/certdata/capath \
test/cjkencodings \
Expand Down Expand Up @@ -2290,8 +2291,7 @@ TESTSUBDIRS= idlelib/idle_test \
test/tracedmodules \
test/typinganndata \
test/xmltestdata \
test/xmltestdata/c14n-20 \
test/ziptestdata
test/xmltestdata/c14n-20

COMPILEALL_OPTS=-j0

Expand Down
Loading