Added check for supported tar and 7z codecs
This commit is contained in:
parent
30c58834bd
commit
ef668ddc94
|
@ -93,3 +93,23 @@ def needs_program (program):
|
||||||
newfunc.func_name = f.func_name
|
newfunc.func_name = f.func_name
|
||||||
return newfunc
|
return newfunc
|
||||||
return check_prog
|
return check_prog
|
||||||
|
|
||||||
|
|
||||||
|
def needs_codec (program, codec):
|
||||||
|
"""Decorator skipping test if given program codec is not available."""
|
||||||
|
def check_prog (f):
|
||||||
|
def newfunc (*args, **kwargs):
|
||||||
|
if not find_codec(program, codec):
|
||||||
|
raise nose.SkipTest("codec `%s' for program `%s' not available" % (codec, program))
|
||||||
|
return f(*args, **kwargs)
|
||||||
|
newfunc.func_name = f.func_name
|
||||||
|
return newfunc
|
||||||
|
return check_prog
|
||||||
|
|
||||||
|
|
||||||
|
def find_codec (program, codec):
|
||||||
|
if program == '7z' and codec == 'rar':
|
||||||
|
return os.path.exists('/usr/lib/p7zip/Codecs/Rar29.so')
|
||||||
|
if program == 'tar':
|
||||||
|
return find_executable(codec)
|
||||||
|
return False
|
||||||
|
|
|
@ -13,27 +13,70 @@
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
from . import ArchiveTest, needs_program
|
from . import ArchiveTest, needs_program, needs_codec
|
||||||
|
|
||||||
class TestArchives (ArchiveTest):
|
class TestArchives (ArchiveTest):
|
||||||
|
|
||||||
@needs_program('tar')
|
@needs_program('tar')
|
||||||
def test_tar (self):
|
def test_tar (self):
|
||||||
self.program = 'tar'
|
self.program = 'tar'
|
||||||
self.tar_test()
|
self.archive_commands('t.tar')
|
||||||
|
|
||||||
|
@needs_codec('tar', 'gzip')
|
||||||
|
def test_tar_gz (self):
|
||||||
|
self.program = 'tar'
|
||||||
|
self.archive_commands('t.tar.gz')
|
||||||
|
|
||||||
|
@needs_codec('tar', 'compress')
|
||||||
|
def test_tar_z (self):
|
||||||
|
self.program = 'tar'
|
||||||
|
self.archive_commands('t.tar.Z')
|
||||||
|
|
||||||
|
@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')
|
||||||
|
|
||||||
|
@needs_codec('tar', 'xz')
|
||||||
|
def test_tar_xz (self):
|
||||||
|
self.program = 'tar'
|
||||||
|
self.archive_commands('t.tar.xz')
|
||||||
|
|
||||||
@needs_program('star')
|
@needs_program('star')
|
||||||
def test_star (self):
|
def test_star (self):
|
||||||
self.program = 'star'
|
self.program = 'star'
|
||||||
self.tar_test()
|
|
||||||
|
|
||||||
def tar_test (self):
|
|
||||||
self.archive_commands('t.tar')
|
self.archive_commands('t.tar')
|
||||||
|
|
||||||
|
@needs_codec('tar', 'gzip')
|
||||||
|
def test_star_gz (self):
|
||||||
|
self.program = 'star'
|
||||||
self.archive_commands('t.tar.gz')
|
self.archive_commands('t.tar.gz')
|
||||||
|
|
||||||
|
@needs_codec('tar', 'compress')
|
||||||
|
def test_star_z (self):
|
||||||
|
self.program = 'star'
|
||||||
self.archive_commands('t.tar.Z')
|
self.archive_commands('t.tar.Z')
|
||||||
|
|
||||||
|
@needs_codec('tar', 'bzip2')
|
||||||
|
def test_star_bz2 (self):
|
||||||
|
self.program = 'star'
|
||||||
self.archive_commands('t.tar.bz2')
|
self.archive_commands('t.tar.bz2')
|
||||||
self.archive_commands('t.tbz2')
|
self.archive_commands('t.tbz2')
|
||||||
|
|
||||||
|
@needs_codec('tar', 'lzma')
|
||||||
|
def test_star_lzma (self):
|
||||||
|
self.program = 'star'
|
||||||
self.archive_commands('t.tar.lzma')
|
self.archive_commands('t.tar.lzma')
|
||||||
|
|
||||||
|
@needs_codec('tar', 'xz')
|
||||||
|
def test_star_xz (self):
|
||||||
|
self.program = 'star'
|
||||||
self.archive_commands('t.tar.xz')
|
self.archive_commands('t.tar.xz')
|
||||||
|
|
||||||
@needs_program('bzip2')
|
@needs_program('bzip2')
|
||||||
|
@ -120,6 +163,7 @@ class TestArchives (ArchiveTest):
|
||||||
self.archive_test('t.deb')
|
self.archive_test('t.deb')
|
||||||
|
|
||||||
@needs_program('7z')
|
@needs_program('7z')
|
||||||
|
@needs_codec('7z', 'rar')
|
||||||
def test_p7zip_rar (self):
|
def test_p7zip_rar (self):
|
||||||
# only succeeds with the rar module for 7z installed
|
# only succeeds with the rar module for 7z installed
|
||||||
self.program = '7z'
|
self.program = '7z'
|
||||||
|
|
Loading…
Reference in New Issue