Page MenuHomeSoftware Heritage

Jenkins > .tox.py3-core-db-server-github-slow-cover.lib.python3.7.site-packages.swh.core.tests.test_tarball::test_uncompress_archive_no_extension
Failed

TEST RESULT

Run At
Jun 16 2022, 9:05 AM
Details
tarpath = '/tmp/pytest-of-jenkins/pytest-0/test_uncompress_archive_no_ext0/67701b18568b2eced3102f83210ccb13' dest = '/tmp/pytest-of-jenkins/pytest-0/test_uncompress_archive_no_ext0/ca-certificates-20210603-1-any.pkg.tar.zst' def uncompress(tarpath: str, dest: str): """Uncompress tarpath to dest folder if tarball is supported. Note that this fixes permissions after successfully uncompressing the archive. Args: tarpath: path to tarball to uncompress dest: the destination folder where to uncompress the tarball, it will be created if it does not exist Raises: ValueError when a problem occurs during unpacking """ try: os.makedirs(dest, exist_ok=True) format = None # try to get archive format from extension for format_, exts, _ in shutil.get_unpack_formats(): if any([tarpath.lower().endswith(ext.lower()) for ext in exts]): format = format_ break # try to get archive format from file mimetype if format is None: m = magic.Magic(mime=True) mime = m.from_file(tarpath) format = _mime_to_archive_format.get(mime) > shutil.unpack_archive(tarpath, extract_dir=dest, format=format) .tox/py3-core-db-server-github-slow-cover/lib/python3.7/site-packages/swh/core/tarball.py:160: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ filename = '/tmp/pytest-of-jenkins/pytest-0/test_uncompress_archive_no_ext0/67701b18568b2eced3102f83210ccb13' extract_dir = '/tmp/pytest-of-jenkins/pytest-0/test_uncompress_archive_no_ext0/ca-certificates-20210603-1-any.pkg.tar.zst' format = None 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 func = format_info[1] func(filename, extract_dir, **dict(format_info[2])) else: # we need to look at the registered unpackers supported extensions format = _find_unpack_format(filename) if format is None: > raise ReadError("Unknown archive format '{0}'".format(filename)) E shutil.ReadError: Unknown archive format '/tmp/pytest-of-jenkins/pytest-0/test_uncompress_archive_no_ext0/67701b18568b2eced3102f83210ccb13' /usr/lib/python3.7/shutil.py:995: ReadError During handling of the above exception, another exception occurred: tmp_path = PosixPath('/tmp/pytest-of-jenkins/pytest-0/test_uncompress_archive_no_ext0') datadir = '/var/lib/jenkins/workspace/DCORE/tests-on-diff/.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:253: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tarpath = '/tmp/pytest-of-jenkins/pytest-0/test_uncompress_archive_no_ext0/67701b18568b2eced3102f83210ccb13' dest = '/tmp/pytest-of-jenkins/pytest-0/test_uncompress_archive_no_ext0/ca-certificates-20210603-1-any.pkg.tar.zst' def uncompress(tarpath: str, dest: str): """Uncompress tarpath to dest folder if tarball is supported. Note that this fixes permissions after successfully uncompressing the archive. Args: tarpath: path to tarball to uncompress dest: the destination folder where to uncompress the tarball, it will be created if it does not exist Raises: ValueError when a problem occurs during unpacking """ try: os.makedirs(dest, exist_ok=True) format = None # try to get archive format from extension for format_, exts, _ in shutil.get_unpack_formats(): if any([tarpath.lower().endswith(ext.lower()) for ext in exts]): format = format_ break # try to get archive format from file mimetype if format is None: m = magic.Magic(mime=True) mime = m.from_file(tarpath) format = _mime_to_archive_format.get(mime) shutil.unpack_archive(tarpath, extract_dir=dest, format=format) except shutil.ReadError as e: > raise ValueError(f"Problem during unpacking {tarpath}. Reason: {e}") E ValueError: Problem during unpacking /tmp/pytest-of-jenkins/pytest-0/test_uncompress_archive_no_ext0/67701b18568b2eced3102f83210ccb13. Reason: Unknown archive format '/tmp/pytest-of-jenkins/pytest-0/test_uncompress_archive_no_ext0/67701b18568b2eced3102f83210ccb13' .tox/py3-core-db-server-github-slow-cover/lib/python3.7/site-packages/swh/core/tarball.py:162: ValueError