tmp_path = PosixPath('/tmp/pytest-of-jenkins/pytest-0/test_uncompress_archive_no_ext0')
datadir = '/var/lib/jenkins/workspace/DCORE/tests-on-diff@2/.tox/py3-core-db-server-github-slow-cover/lib/python3.7/site-packages/swh/core/tests/data'
def test_uncompress_archive_no_extension(tmp_path, datadir):
"""Copy test archives in a temporary directory but turn their names
to their md5 sums, then check they can be successfully extracted.
"""
archives_path = os.path.join(datadir, "archives")
archive_files = [
f
for f in os.listdir(archives_path)
if os.path.isfile(os.path.join(archives_path, f))
]
for archive_file in archive_files:
archive_file_path = os.path.join(archives_path, archive_file)
with open(archive_file_path, "rb") as f:
md5sum = hashlib.md5(f.read()).hexdigest()
archive_file_md5sum = os.path.join(tmp_path, md5sum)
extract_dir = os.path.join(tmp_path, archive_file)
shutil.copy(archive_file_path, archive_file_md5sum)
> tarball.uncompress(archive_file_md5sum, extract_dir)
.tox/py3-core-db-server-github-slow-cover/lib/python3.7/site-packages/swh/core/tests/test_tarball.py:283:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3-core-db-server-github-slow-cover/lib/python3.7/site-packages/swh/core/tarball.py:161: in uncompress
shutil.unpack_archive(tarpath, extract_dir=dest, format=format)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
filename = '/tmp/pytest-of-jenkins/pytest-0/test_uncompress_archive_no_ext0/8e0a45e1991f77e19373f4f1c9afbc37'
extract_dir = '/tmp/pytest-of-jenkins/pytest-0/test_uncompress_archive_no_ext0/hello.jar'
format = 'jar'
def unpack_archive(filename, extract_dir=None, format=None):
"""Unpack an archive.
`filename` is the name of the archive.
`extract_dir` is the name of the target directory, where the archive
is unpacked. If not provided, the current working directory is used.
`format` is the archive format: one of "zip", "tar", "gztar", "bztar",
or "xztar". Or any other registered format. If not provided,
unpack_archive will use the filename extension and see if an unpacker
was registered for that extension.
In case none is found, a ValueError is raised.
"""
if extract_dir is None:
extract_dir = os.getcwd()
extract_dir = os.fspath(extract_dir)
filename = os.fspath(filename)
if format is not None:
try:
format_info = _UNPACK_FORMATS[format]
except KeyError:
> raise ValueError("Unknown unpack format '{0}'".format(format)) from None
E ValueError: Unknown unpack format 'jar'
/usr/lib/python3.7/shutil.py:987: ValueError
TEST RESULT
TEST RESULT
- Run At
- Oct 24 2022, 4:42 PM