patool/tests/test_archives.py

528 lines
16 KiB
Python
Raw Normal View History

2010-02-21 11:14:57 +00:00
# -*- coding: utf-8 -*-
2012-04-08 16:54:37 +00:00
# Copyright (C) 2010-2012 Bastian Kleineidam
2010-02-21 11:14:57 +00:00
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2012-05-25 19:22:40 +00:00
from . import ArchiveTest, needs_os, needs_program, needs_codec, Content
2010-02-21 11:14:57 +00:00
class TestArchives (ArchiveTest):
@needs_program('tar')
2010-02-21 11:14:57 +00:00
def test_tar (self):
self.program = 'tar'
self.archive_commands('t.tar')
@needs_codec('tar', 'gzip')
def test_tar_gz (self):
self.program = 'tar'
self.archive_commands('t.tar.gz')
2010-02-23 18:30:58 +00:00
self.archive_commands('t.tgz')
@needs_program('tar')
@needs_program('compress')
def test_tar_z (self):
self.program = 'tar'
self.archive_commands('t.tar.Z')
2010-02-23 18:30:58 +00:00
self.archive_commands('t.taz')
@needs_codec('tar', 'bzip2')
def test_tar_bz2 (self):
self.program = 'tar'
self.archive_commands('t.tar.bz2')
self.archive_commands('t.tbz2')
@needs_codec('tar', 'lzma')
def test_tar_lzma (self):
self.program = 'tar'
self.archive_commands('t.tar.lzma')
2011-10-19 07:27:45 +00:00
# even though clzip would support extracting .lz files, the
2011-01-17 19:11:02 +00:00
# file(1) --uncompress command does not use it for achive detection
@needs_program('tar')
2011-01-17 19:11:02 +00:00
@needs_program('lzip')
2010-03-04 15:42:37 +00:00
def test_tar_lzip (self):
self.program = 'tar'
self.archive_commands('t.tar.lz')
@needs_codec('tar', 'xz')
def test_tar_xz (self):
self.program = 'tar'
self.archive_commands('t.tar.xz')
2010-02-21 11:14:57 +00:00
@needs_program('star')
2010-02-21 11:14:57 +00:00
def test_star (self):
self.program = 'star'
self.archive_commands('t.tar')
@needs_codec('star', 'gzip')
def test_star_gz (self):
self.program = 'star'
self.archive_commands('t.tar.gz')
2010-02-23 18:30:58 +00:00
self.archive_commands('t.tgz')
@needs_program('star')
@needs_program('compress')
def test_star_z (self):
self.program = 'star'
self.archive_commands('t.tar.Z')
2010-02-23 18:30:58 +00:00
self.archive_commands('t.taz')
@needs_codec('star', 'bzip2')
def test_star_bz2 (self):
self.program = 'star'
self.archive_commands('t.tar.bz2')
self.archive_commands('t.tbz2')
@needs_codec('star', 'lzma')
def test_star_lzma (self):
self.program = 'star'
self.archive_commands('t.tar.lzma')
@needs_program('star')
@needs_program('lzip')
2010-03-04 15:42:37 +00:00
def test_star_lzip (self):
self.program = 'star'
self.archive_commands('t.tar.lz')
@needs_codec('star', 'xz')
def test_star_xz (self):
self.program = 'star'
self.archive_commands('t.tar.xz')
2012-05-23 16:35:54 +00:00
@needs_program('bsdtar')
def test_bsdtar (self):
self.program = 'bsdtar'
self.archive_commands('t.tar')
@needs_codec('bsdtar', 'gzip')
def test_bsdtar_gz (self):
self.program = 'bsdtar'
self.archive_commands('t.tar.gz')
self.archive_commands('t.tgz')
@needs_program('bsdtar')
@needs_program('compress')
def test_bsdtar_z (self):
self.program = 'bsdtar'
self.archive_commands('t.tar.Z')
self.archive_commands('t.taz')
@needs_codec('bsdtar', 'bzip2')
def test_bsdtar_bz2 (self):
self.program = 'bsdtar'
self.archive_commands('t.tar.bz2')
self.archive_commands('t.tbz2')
@needs_codec('bsdtar', 'lzma')
def test_bsdtar_lzma (self):
self.program = 'bsdtar'
self.archive_commands('t.tar.lzma')
# even though clzip would support extracting .lz files, the
# file(1) --uncompress command does not use it for achive detection
@needs_program('bsdtar')
@needs_program('lzip')
def test_bsdtar_lzip (self):
self.program = 'bsdtar'
self.archive_commands('t.tar.lz')
@needs_codec('bsdtar', 'xz')
def test_bsdtar_xz (self):
self.program = 'bsdtar'
self.archive_commands('t.tar.xz')
def test_py_tarfile (self):
self.program = 'py_tarfile'
self.archive_commands('t.tar')
def test_py_tarfile_gz (self):
self.program = 'py_tarfile'
self.archive_commands('t.tar.gz')
self.archive_commands('t.tgz')
def test_py_tarfile_bz2 (self):
self.program = 'py_tarfile'
self.archive_commands('t.tar.bz2')
self.archive_commands('t.tbz2')
@needs_program('bzip2')
2010-02-21 11:14:57 +00:00
def test_bzip2 (self):
self.program = 'bzip2'
2012-05-25 19:22:40 +00:00
self.archive_extract('t.txt.bz2', check=Content.Singlefile)
2012-05-24 21:09:37 +00:00
self.archive_test('t.txt.bz2')
self.archive_create('t.txt.bz2', singlefile=True)
2010-02-21 11:14:57 +00:00
@needs_program('bzip2')
def test_py_bz2 (self):
self.program = 'py_bz2'
2012-05-25 19:22:40 +00:00
self.archive_extract('t.txt.bz2', check=Content.Singlefile)
# bzip2 is used to test the created archive
2012-05-24 21:09:37 +00:00
self.archive_create('t.txt.bz2', singlefile=True)
@needs_program('pbzip2')
2010-02-21 11:14:57 +00:00
def test_pbzip2 (self):
self.program = 'pbzip2'
2012-05-25 19:22:40 +00:00
self.archive_extract('t.txt.bz2', check=Content.Singlefile)
2012-05-24 21:09:37 +00:00
self.archive_test('t.txt.bz2')
self.archive_create('t.txt.bz2', singlefile=True)
2010-02-21 11:14:57 +00:00
2012-05-11 05:08:50 +00:00
@needs_program('lbzip2')
def test_lbzip2 (self):
self.program = 'lbzip2'
2012-05-25 19:22:40 +00:00
self.archive_extract('t.txt.bz2', check=Content.Singlefile)
2012-05-24 21:09:37 +00:00
self.archive_test('t.txt.bz2')
self.archive_create('t.txt.bz2', singlefile=True)
2012-05-11 05:08:50 +00:00
def test_py_echo (self):
self.program = 'py_echo'
2012-05-24 21:09:37 +00:00
self.archive_list('t.txt.bz2')
self.archive_list('t.txt.Z')
self.archive_list('t.txt.lzma')
2010-03-04 15:42:37 +00:00
self.archive_list('t.txt.lz')
2010-03-08 18:58:39 +00:00
self.archive_list('t.txt.lrz')
2010-03-20 10:34:40 +00:00
self.archive_list('t.txt.rz')
2012-05-17 09:01:06 +00:00
self.archive_list('t.ape')
2012-05-17 12:28:12 +00:00
self.archive_list('t.shn')
2012-05-17 19:22:56 +00:00
self.archive_list('t.flac')
2010-02-21 11:14:57 +00:00
@needs_program('unzip')
2010-02-21 11:14:57 +00:00
def test_unzip (self):
self.program = 'unzip'
2012-05-25 19:22:40 +00:00
self.archive_extract('t.zip', check=None)
self.archive_list('t.zip')
self.archive_test('t.zip')
2012-05-25 19:22:40 +00:00
self.archive_extract('t.jar', check=None)
self.archive_list('t.jar')
self.archive_test('t.jar')
@needs_program('zip')
def test_zip (self):
self.program = 'zip'
self.archive_create('t.zip')
def test_py_zipfile (self):
self.program = 'py_zipfile'
self.archive_commands('t.zip')
@needs_program('gzip')
2010-02-21 11:14:57 +00:00
def test_gzip (self):
self.program = 'gzip'
self.archive_commands('t.txt.gz', singlefile=True)
2012-05-25 19:22:40 +00:00
self.archive_extract('t.txt.Z', check=Content.Singlefile)
2010-02-21 11:14:57 +00:00
@needs_program('gzip')
def test_py_gzip (self):
self.program = 'py_gzip'
2012-05-25 19:22:40 +00:00
self.archive_extract('t.txt.gz', check=Content.Singlefile)
# gzip is used to test the created archive
2012-05-24 21:09:37 +00:00
self.archive_create('t.txt.gz', singlefile=True)
@needs_program('pigz')
def test_pigz (self):
self.program = 'pigz'
self.archive_commands('t.txt.gz', singlefile=True)
@needs_program('uncompress.real')
2010-02-21 11:14:57 +00:00
def test_uncompress (self):
self.program = 'uncompress.real'
2012-05-25 19:22:40 +00:00
self.archive_extract('t.txt.Z', check=Content.Singlefile)
2010-02-21 11:14:57 +00:00
@needs_program('compress')
2010-02-21 14:48:52 +00:00
def test_compress (self):
self.program = 'compress'
2012-05-24 21:09:37 +00:00
self.archive_create('t.txt.Z', singlefile=True)
2010-02-21 14:48:52 +00:00
@needs_program('7z')
2010-02-21 11:14:57 +00:00
def test_p7zip (self):
self.program = '7z'
2010-04-05 00:56:32 +00:00
self.archive_commands('t .7z')
self.archive_commands('t.zip')
2012-05-24 21:09:37 +00:00
self.archive_list('t.txt.gz')
self.archive_list('t.txt.bz2')
self.archive_list('t.jar')
2012-05-24 21:09:37 +00:00
self.archive_list('t.txt.Z')
self.archive_list('t.cab')
self.archive_list('t.arj')
self.archive_list('t.cpio')
self.archive_list('t.rpm')
self.archive_list('t.deb')
2012-05-25 19:22:40 +00:00
self.archive_extract('t.txt.gz', check=Content.Singlefile)
self.archive_extract('t.txt.bz2', check=Content.Singlefile)
self.archive_extract('t.jar', check=None)
self.archive_extract('t.txt.Z', check=Content.Singlefile)
self.archive_extract('t.cab')
self.archive_extract('t.arj')
self.archive_extract('t.cpio')
2012-05-25 19:22:40 +00:00
self.archive_extract('t.rpm', check=None)
self.archive_extract('t.deb', check=None)
2012-05-24 21:09:37 +00:00
self.archive_test('t.txt.gz')
self.archive_test('t.txt.bz2')
self.archive_test('t.jar')
2012-05-24 21:09:37 +00:00
self.archive_test('t.txt.Z')
self.archive_test('t.cab')
self.archive_test('t.arj')
self.archive_test('t.cpio')
self.archive_test('t.rpm')
self.archive_test('t.deb')
@needs_codec('7z', 'rar')
def test_p7zip_rar (self):
# only succeeds with the rar module for 7z installed
self.program = '7z'
self.archive_list('t.rar')
self.archive_extract('t.rar')
self.archive_test('t.rar')
@needs_program('7za')
def test_p7azip (self):
# unsupported actions of the 7za standalone program are commented out
self.program = '7za'
self.archive_commands('t .7z')
self.archive_commands('t.zip')
2012-05-24 21:09:37 +00:00
self.archive_list('t.txt.gz')
self.archive_list('t.txt.bz2')
self.archive_list('t.jar')
2012-05-24 21:09:37 +00:00
self.archive_list('t.txt.Z')
self.archive_list('t.cab')
#self.archive_list('t.arj')
#self.archive_list('t.cpio')
self.archive_list('t.rpm')
#self.archive_list('t.deb')
2012-05-25 19:22:40 +00:00
self.archive_extract('t.txt.gz', check=Content.Singlefile)
self.archive_extract('t.txt.bz2', check=Content.Singlefile)
self.archive_extract('t.jar', check=None)
self.archive_extract('t.txt.Z', check=Content.Singlefile)
self.archive_extract('t.cab')
#self.archive_extract('t.arj')
#self.archive_extract('t.cpio')
2012-05-25 19:22:40 +00:00
#self.archive_extract('t.rpm', check=None)
#self.archive_extract('t.deb', check=None)
2012-05-24 21:09:37 +00:00
self.archive_test('t.txt.gz')
self.archive_test('t.txt.bz2')
self.archive_test('t.jar')
2012-05-24 21:09:37 +00:00
self.archive_test('t.txt.Z')
self.archive_test('t.cab')
#self.archive_test('t.arj')
#self.archive_test('t.cpio')
#self.archive_test('t.rpm')
#self.archive_test('t.deb')
@needs_program('unrar')
2010-02-21 11:14:57 +00:00
def test_unrar (self):
self.program = 'unrar'
self.archive_list('t.rar')
self.archive_extract('t.rar')
2010-02-21 11:14:57 +00:00
@needs_program('rar')
2010-02-21 11:14:57 +00:00
def test_rar (self):
self.program = 'rar'
self.archive_commands('t.rar')
2010-02-21 11:14:57 +00:00
@needs_program('cabextract')
2010-02-21 14:48:52 +00:00
def test_cabextract (self):
self.program = 'cabextract'
self.archive_list('t.cab')
2012-05-25 19:22:40 +00:00
self.archive_extract('t.cab', check=None)
2010-02-21 11:14:57 +00:00
@needs_program('orange')
2011-01-24 20:28:29 +00:00
def test_orange (self):
self.program = 'orange'
self.archive_extract('t.cab')
2012-05-24 21:17:37 +00:00
@needs_program('lcab')
@needs_program('cabextract')
def test_lcab (self):
self.program = 'lcab'
self.archive_create('t.cab')
@needs_program('arj')
2010-02-21 11:14:57 +00:00
def test_arj (self):
self.program = 'arj'
self.archive_commands('t.arj')
2010-02-21 11:14:57 +00:00
@needs_os('posix')
2010-03-06 15:52:13 +00:00
@needs_program('ar')
def test_ar (self):
self.program = 'ar'
2012-05-25 13:01:18 +00:00
self.archive_commands('t.txt.a', singlefile=True)
2010-03-06 15:52:13 +00:00
@needs_program('cpio')
2010-02-21 11:14:57 +00:00
def test_cpio (self):
self.program = 'cpio'
2012-05-23 16:22:16 +00:00
self.archive_commands('t.cpio')
2012-05-23 03:46:09 +00:00
2012-05-23 16:22:16 +00:00
@needs_program('bsdcpio')
def test_bsdcpio (self):
self.program = 'bsdcpio'
self.archive_commands('t.cpio')
2010-02-21 11:14:57 +00:00
2010-03-06 14:47:00 +00:00
@needs_program('unace')
def test_unace (self):
self.program = 'unace'
self.archive_list('t.ace')
self.archive_test('t.ace')
self.archive_extract('t.ace')
@needs_program('rpm')
2010-02-21 11:14:57 +00:00
def test_rpm (self):
self.program = 'rpm'
self.archive_list('t.rpm')
# The rpm test fails on non-rpm system with missing dependencies.
# I am too lazy to build a tiny rpm with one file
# and no dependency.
#self.archive_test('t.rpm')
2010-02-21 11:14:57 +00:00
@needs_program('rpm2cpio')
@needs_program('cpio')
2010-02-21 11:14:57 +00:00
def test_rpm_extract (self):
self.program = 'rpm2cpio'
2012-05-25 19:22:40 +00:00
self.archive_extract('t.rpm', check=None)
2010-02-21 11:14:57 +00:00
@needs_program('dpkg-deb')
2010-02-21 11:14:57 +00:00
def test_dpkg (self):
self.program = 'dpkg'
self.archive_list('t.deb')
2012-05-25 19:22:40 +00:00
self.archive_extract('t.deb', check=None)
self.archive_test('t.deb')
2010-02-21 11:14:57 +00:00
@needs_program('lzop')
2010-02-21 11:14:57 +00:00
def test_lzop (self):
self.program = 'lzop'
self.archive_commands('t.lzo', singlefile=True)
2010-02-21 11:14:57 +00:00
@needs_program('lzma')
2010-02-22 16:21:55 +00:00
def test_lzma (self):
self.program = 'lzma'
2012-05-24 21:09:37 +00:00
self.archive_test('t.txt.lzma')
2012-05-25 19:22:40 +00:00
self.archive_extract('t.txt.lzma', check=Content.Singlefile)
2012-05-24 21:09:37 +00:00
self.archive_create('t.txt.lzma', singlefile=True)
2010-02-22 16:21:55 +00:00
2010-03-04 15:42:37 +00:00
@needs_program('lzip')
def test_lzip (self):
self.program = 'lzip'
self.archive_test('t.txt.lz')
2012-05-25 19:22:40 +00:00
self.archive_extract('t.txt.lz', check=Content.Singlefile)
2010-03-04 15:42:37 +00:00
self.archive_create('t.txt.lz', singlefile=True)
2011-01-17 19:11:02 +00:00
@needs_program('clzip')
def test_clzip (self):
self.program = 'clzip'
self.archive_test('t.txt.lz')
2012-05-25 19:22:40 +00:00
self.archive_extract('t.txt.lz', check=Content.Singlefile)
2011-01-17 19:11:02 +00:00
self.archive_create('t.txt.lz', singlefile=True)
2012-05-11 05:14:49 +00:00
@needs_program('plzip')
def test_plzip (self):
self.program = 'plzip'
self.archive_test('t.txt.lz')
2012-05-25 19:22:40 +00:00
self.archive_extract('t.txt.lz', check=Content.Singlefile)
2012-05-11 05:14:49 +00:00
self.archive_create('t.txt.lz', singlefile=True)
2011-01-17 19:27:54 +00:00
@needs_program('pdlzip')
2011-01-24 20:28:29 +00:00
def test_pdlzip (self):
2011-01-17 19:27:54 +00:00
self.program = 'pdlzip'
self.archive_test('t.txt.lz')
2012-05-25 19:22:40 +00:00
self.archive_extract('t.txt.lz', check=Content.Singlefile)
2011-01-17 19:27:54 +00:00
self.archive_create('t.txt.lz', singlefile=True)
@needs_program('unalz')
def test_unalz (self):
self.program = 'unalz'
self.archive_test('t.alz')
self.archive_list('t.alz')
self.archive_extract('t.alz')
@needs_program('xz')
2010-02-22 16:34:08 +00:00
def test_xz (self):
self.program = 'xz'
2012-05-24 21:09:37 +00:00
self.archive_commands('t.txt.xz', singlefile=True)
@needs_program('lha')
def test_lha (self):
self.program = 'lha'
self.archive_commands('t.lha')
2010-03-08 17:28:11 +00:00
@needs_program('lhasa')
def test_lhasa (self):
self.program = 'lhasa'
self.archive_extract('t.lha')
2010-03-08 17:28:11 +00:00
@needs_program('arc')
def test_arc (self):
self.program = 'arc'
self.archive_commands('t.arc', singlefile=True)
@needs_program('nomarch')
def test_nomarch (self):
self.program = 'nomarch'
self.archive_test('t.arc')
self.archive_list('t.arc')
self.archive_extract('t.arc')
2010-03-08 18:58:39 +00:00
@needs_program('lrzip')
def test_lrzip (self):
self.program = 'lrzip'
self.archive_test('t.txt.lrz')
self.archive_extract('t.txt.lrz')
2010-12-16 07:12:15 +00:00
self.archive_create('t.txt.lrz', singlefile=True)
2010-03-20 10:34:40 +00:00
@needs_program('rzip')
def test_rzip (self):
self.program = 'rzip'
self.archive_extract('t.txt.rz')
self.archive_create('t.txt.rz', singlefile=True)
2010-03-21 14:39:02 +00:00
2010-12-16 07:12:15 +00:00
@needs_program('zoo')
def test_zoo (self):
self.program = 'zoo'
2011-10-19 07:27:45 +00:00
# XXX test failure - zoo cannot read its own files back :-(
2010-12-16 07:12:15 +00:00
#self.archive_commands('t.zoo', singlefile=True)
2011-01-24 20:28:29 +00:00
@needs_program('xdms')
def test_xdms (self):
self.program = 'xdms'
self.archive_test('t.dms')
self.archive_extract('t.dms')
self.archive_list('t.dms')
@needs_program('mac')
def test_mac (self):
self.program = 'mac'
2012-05-25 19:22:40 +00:00
self.archive_extract('t.ape', check=None)
2012-05-17 09:01:06 +00:00
self.archive_test('t.ape')
2012-05-17 09:31:00 +00:00
self.archive_create('t.ape', srcfile="t.wav")
2012-05-17 12:28:12 +00:00
@needs_program('shorten')
def test_shorten (self):
self.program = 'shorten'
2012-05-25 19:22:40 +00:00
self.archive_extract('t.shn', check=None)
2012-05-17 12:28:12 +00:00
self.archive_create('t.shn', srcfile="t.wav")
2012-05-17 19:22:56 +00:00
@needs_program('flac')
def test_flac (self):
self.program = 'flac'
2012-05-25 19:22:40 +00:00
self.archive_extract('t.flac', check=None)
2012-05-17 19:22:56 +00:00
self.archive_test('t.flac')
self.archive_create('t.flac', srcfile="t.wav")
2012-05-25 20:07:22 +00:00
@needs_program('shar')
2012-05-27 18:37:07 +00:00
@needs_program('unshar')
2012-05-25 20:07:22 +00:00
def test_shar (self):
self.program = 'shar'
self.archive_create('t.shar', singlefile=True)
@needs_program('unshar')
def test_unshar (self):
self.program = 'unshar'
self.archive_extract('t.shar', check=None)