Split archive tests

This commit is contained in:
Bastian Kleineidam 2012-11-14 20:24:34 +01:00
parent d8407a73ce
commit f409b5bba6
57 changed files with 2293 additions and 1278 deletions

View File

@ -13,218 +13,20 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import unittest
import os
import shutil
import nose
import patoolib
# All text files have '42' as content.
TextFileContent = '42'
class Content:
"""The test archives have one of several set of content files.
The different content file sets have each a constant defined
by this class.
"""
# Recursive archives for extraction have a text file in a directory:
# t/t.txt
# Recursive archives for creation have two text files in directories:
# foo dir/t.txt
# foo dir/bar/t.txt
Recursive = 'recursive'
# Singlefile archives for extraction have a text file t.txt
# Recursive archives for creation have a text file `foo .txt'
Singlefile = 'singlefile'
import pytest
basedir = os.path.dirname(__file__)
datadir = os.path.join(basedir, 'data')
class ArchiveTest (unittest.TestCase):
"""Helper class for achive tests."""
def __init__ (self, *args):
"""Initialize this archive test."""
super(ArchiveTest, self).__init__(*args)
# set program to use for archive handling
self.program = None
def archive_commands (self, filename, **kwargs):
"""Run archive commands list, test, extract and create.
All keyword arguments are delegated to the create test function."""
self.archive_list(filename)
self.archive_test(filename)
if kwargs.get('singlefile'):
check_default = Content.Singlefile
else:
check_default = Content.Recursive
check = kwargs.get('check', check_default)
if 'check' in kwargs:
del kwargs['check']
self.archive_extract(filename, check=check)
if not kwargs.get('skip_create'):
self.archive_create(filename, **kwargs)
def archive_extract (self, filename, check=Content.Recursive):
"""Test archive extraction."""
archive = os.path.join(datadir, filename)
self.assertTrue(os.path.isabs(archive), "archive path is not absolute: %r" % archive)
self._archive_extract(archive, check)
# archive name relative to tmpdir
relarchive = os.path.join("..", archive[len(basedir)+1:])
self._archive_extract(relarchive, check, verbose=True)
def _archive_extract (self, archive, check, verbose=False):
# create a temporary directory for extraction
tmpdir = patoolib.util.tmpdir(dir=basedir)
try:
olddir = os.getcwd()
except OSError:
olddir = None
os.chdir(tmpdir)
try:
output = patoolib._handle_archive(archive, 'extract', program=self.program, verbose=verbose)
if check:
self.check_extracted_archive(archive, output, check)
finally:
if olddir:
os.chdir(olddir)
shutil.rmtree(tmpdir)
def check_extracted_archive (self, archive, output, check):
if check == Content.Recursive:
# outdir is the 't' directory of the archive
self.assertEqual(output, 't')
self.check_directory(output, 't')
txtfile = os.path.join(output, 't.txt')
self.check_textfile(txtfile, 't.txt')
elif check == Content.Singlefile:
# a non-existing directory to ensure files do not exist in it
ned = get_nonexisting_directory()
expected_output = os.path.basename(patoolib.util.get_single_outfile(ned, archive))
self.check_textfile(output, expected_output)
def check_directory (self, dirname, expectedname):
self.assertTrue(os.path.isdir(dirname), dirname)
self.assertEqual(os.path.basename(dirname), expectedname)
def check_textfile (self, filename, expectedname):
self.assertTrue(os.path.isfile(filename), filename)
self.assertEqual(os.path.basename(filename), expectedname)
self.assertEqual(get_filecontent(filename), TextFileContent)
def archive_list (self, filename):
"""Test archive listing."""
archive = os.path.join(datadir, filename)
patoolib._handle_archive(archive, 'list', program=self.program)
patoolib._handle_archive(archive, 'list', program=self.program, verbose=True)
def archive_test (self, filename):
"""Test archive testing."""
archive = os.path.join(datadir, filename)
patoolib._handle_archive(archive, 'test', program=self.program)
patoolib._handle_archive(archive, 'test', program=self.program, verbose=True)
def archive_create (self, archive, srcfile=None, singlefile=False):
"""Test archive creation."""
# determine filename which is added to the archive
if srcfile is None:
if singlefile:
srcfile = 't.txt'
else:
srcfile = 't'
os.chdir(datadir)
# The format and compression arguments are needed for creating
# archives with unusual file extensions.
self._archive_create(archive, srcfile, program=self.program)
# create again in verbose mode
self._archive_create(archive, srcfile, program=self.program,
verbose=True)
def _archive_create (self, archive, srcfile, **kwargs):
"""Create archive from filename."""
self.assertFalse(os.path.isabs(srcfile))
self.assertTrue(os.path.exists(srcfile))
# create a temporary directory for creation
tmpdir = patoolib.util.tmpdir(dir=basedir)
archive = os.path.join(tmpdir, archive)
self.assertTrue(os.path.isabs(archive), "archive path is not absolute: %r" % archive)
try:
patoolib._handle_archive(archive, 'create', srcfile, **kwargs)
self.assertTrue(os.path.isfile(archive))
self.check_created_archive_with_test(archive)
self.check_created_archive_with_diff(archive, srcfile)
finally:
shutil.rmtree(tmpdir)
def check_created_archive_with_test(self, archive):
command = 'test'
program = self.program
# special case for programs that cannot test what they create
if self.program in ('compress', 'py_gzip'):
program = 'gzip'
elif self.program == 'py_bz2':
program = 'bzip2'
elif self.program == 'zip':
program = 'unzip'
elif self.program in ('rzip', 'shorten'):
program = 'py_echo'
command = 'list'
elif self.program == 'lcab':
program = 'cabextract'
elif self.program == 'shar':
return
patoolib._handle_archive(archive, command, program=program)
def check_created_archive_with_diff(self, archive, srcfile):
"""Extract created archive again and compare the contents."""
# diff srcfile and output
diff = patoolib.util.find_program("diff")
if not diff:
return
program = self.program
# special case for programs that cannot extract what they create
if self.program == 'compress':
program = 'gzip'
elif self.program == 'zip':
program = 'unzip'
elif self.program == 'lcab':
program = 'cabextract'
elif self.program == 'shar':
program = 'unshar'
tmpdir = patoolib.util.tmpdir(dir=basedir)
try:
olddir = os.getcwd()
except OSError:
olddir = None
os.chdir(tmpdir)
try:
output = patoolib._handle_archive(archive, 'extract', program=program)
res = patoolib.util.run([diff, "-urN", srcfile, output])
self.assertEqual(res, 0)
finally:
if olddir:
os.chdir(olddir)
shutil.rmtree(tmpdir)
def get_filecontent(filename):
fo = open(filename)
try:
return fo.read()
finally:
fo.close()
def needs_os (name):
"""Decorator skipping test if given program is not available."""
def check_prog (f):
def newfunc (*args, **kwargs):
if os.name != name:
raise nose.SkipTest("operating system %s not found" % name)
raise pytest.skip("operating system %s not found" % name)
return f(*args, **kwargs)
newfunc.func_name = f.func_name
return newfunc
@ -236,7 +38,7 @@ def needs_program (program):
def check_prog (f):
def newfunc (*args, **kwargs):
if not patoolib.util.find_program(program):
raise nose.SkipTest("program `%s' not available" % program)
raise pytest.skip("program `%s' not available" % program)
return f(*args, **kwargs)
newfunc.func_name = f.func_name
return newfunc
@ -251,7 +53,7 @@ def needs_one_program (programs):
if patoolib.util.find_program(program):
break
else:
raise nose.SkipTest("None of programs %s available" % programs)
raise pytest.skip("None of programs %s available" % programs)
return f(*args, **kwargs)
newfunc.func_name = f.func_name
return newfunc
@ -263,9 +65,9 @@ def needs_codec (program, codec):
def check_prog (f):
def newfunc (*args, **kwargs):
if not patoolib.util.find_program(program):
raise nose.SkipTest("program `%s' not available" % program)
raise pytest.skip("program `%s' not available" % program)
if not has_codec(program, codec):
raise nose.SkipTest("codec `%s' for program `%s' not available" % (codec, program))
raise pytest.skip("codec `%s' for program `%s' not available" % (codec, program))
return f(*args, **kwargs)
newfunc.func_name = f.func_name
return newfunc
@ -281,8 +83,3 @@ def has_codec (program, codec):
return patoolib.util.find_program(codec)
def get_nonexisting_directory():
d = os.path.join(os.getcwd(), "foo")
while os.path.exists(d):
d += 'a'
return d

220
tests/archives/__init__.py Normal file
View File

@ -0,0 +1,220 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
import unittest
import os
import shutil
import patoolib
from .. import basedir, datadir
# All text files have '42' as content.
TextFileContent = '42'
class Content:
"""The test archives have one of several set of content files.
The different content file sets have each a constant defined
by this class.
"""
# Recursive archives for extraction have a text file in a directory:
# t/t.txt
# Recursive archives for creation have two text files in directories:
# foo dir/t.txt
# foo dir/bar/t.txt
Recursive = 'recursive'
# Singlefile archives for extraction have a text file t.txt
# Recursive archives for creation have a text file `foo .txt'
Singlefile = 'singlefile'
class ArchiveTest (unittest.TestCase):
"""Helper class for archive tests, handling one commandline program."""
# set program to use for archive handling in subclass
program = None
def archive_commands (self, filename, **kwargs):
"""Run archive commands list, test, extract and create.
All keyword arguments are delegated to the create test function."""
self.archive_list(filename)
self.archive_test(filename)
if kwargs.get('singlefile'):
check_default = Content.Singlefile
else:
check_default = Content.Recursive
check = kwargs.get('check', check_default)
if 'check' in kwargs:
del kwargs['check']
self.archive_extract(filename, check=check)
if not kwargs.get('skip_create'):
self.archive_create(filename, **kwargs)
def archive_extract (self, filename, check=Content.Recursive):
"""Test archive extraction."""
archive = os.path.join(datadir, filename)
self.assertTrue(os.path.isabs(archive), "archive path is not absolute: %r" % archive)
self._archive_extract(archive, check)
# archive name relative to tmpdir
relarchive = os.path.join("..", archive[len(basedir)+1:])
self._archive_extract(relarchive, check, verbose=True)
def _archive_extract (self, archive, check, verbose=False):
# create a temporary directory for extraction
tmpdir = patoolib.util.tmpdir(dir=basedir)
try:
olddir = os.getcwd()
except OSError:
olddir = None
os.chdir(tmpdir)
try:
output = patoolib._handle_archive(archive, 'extract', program=self.program, verbose=verbose)
if check:
self.check_extracted_archive(archive, output, check)
finally:
if olddir:
os.chdir(olddir)
shutil.rmtree(tmpdir)
def check_extracted_archive (self, archive, output, check):
if check == Content.Recursive:
# outdir is the 't' directory of the archive
self.assertEqual(output, 't')
self.check_directory(output, 't')
txtfile = os.path.join(output, 't.txt')
self.check_textfile(txtfile, 't.txt')
elif check == Content.Singlefile:
# a non-existing directory to ensure files do not exist in it
ned = get_nonexisting_directory()
expected_output = os.path.basename(patoolib.util.get_single_outfile(ned, archive))
self.check_textfile(output, expected_output)
def check_directory (self, dirname, expectedname):
self.assertTrue(os.path.isdir(dirname), dirname)
self.assertEqual(os.path.basename(dirname), expectedname)
def check_textfile (self, filename, expectedname):
self.assertTrue(os.path.isfile(filename), filename)
self.assertEqual(os.path.basename(filename), expectedname)
self.assertEqual(get_filecontent(filename), TextFileContent)
def archive_list (self, filename):
"""Test archive listing."""
archive = os.path.join(datadir, filename)
patoolib._handle_archive(archive, 'list', program=self.program)
patoolib._handle_archive(archive, 'list', program=self.program, verbose=True)
def archive_test (self, filename):
"""Test archive testing."""
archive = os.path.join(datadir, filename)
patoolib._handle_archive(archive, 'test', program=self.program)
patoolib._handle_archive(archive, 'test', program=self.program, verbose=True)
def archive_create (self, archive, srcfile=None, singlefile=False):
"""Test archive creation."""
# determine filename which is added to the archive
if srcfile is None:
if singlefile:
srcfile = 't.txt'
else:
srcfile = 't'
os.chdir(datadir)
# The format and compression arguments are needed for creating
# archives with unusual file extensions.
self._archive_create(archive, srcfile, program=self.program)
# create again in verbose mode
self._archive_create(archive, srcfile, program=self.program,
verbose=True)
def _archive_create (self, archive, srcfile, **kwargs):
"""Create archive from filename."""
self.assertFalse(os.path.isabs(srcfile))
self.assertTrue(os.path.exists(srcfile))
# create a temporary directory for creation
tmpdir = patoolib.util.tmpdir(dir=basedir)
archive = os.path.join(tmpdir, archive)
self.assertTrue(os.path.isabs(archive), "archive path is not absolute: %r" % archive)
try:
patoolib._handle_archive(archive, 'create', srcfile, **kwargs)
self.assertTrue(os.path.isfile(archive))
self.check_created_archive_with_test(archive)
self.check_created_archive_with_diff(archive, srcfile)
finally:
shutil.rmtree(tmpdir)
def check_created_archive_with_test(self, archive):
command = 'test'
program = self.program
# special case for programs that cannot test what they create
if self.program in ('compress', 'py_gzip'):
program = 'gzip'
elif self.program == 'py_bz2':
program = 'bzip2'
elif self.program == 'zip':
program = 'unzip'
elif self.program in ('rzip', 'shorten'):
program = 'py_echo'
command = 'list'
elif self.program == 'lcab':
program = 'cabextract'
elif self.program == 'shar':
return
patoolib._handle_archive(archive, command, program=program)
def check_created_archive_with_diff(self, archive, srcfile):
"""Extract created archive again and compare the contents."""
# diff srcfile and output
diff = patoolib.util.find_program("diff")
if not diff:
return
program = self.program
# special case for programs that cannot extract what they create
if self.program == 'compress':
program = 'gzip'
elif self.program == 'zip':
program = 'unzip'
elif self.program == 'lcab':
program = 'cabextract'
elif self.program == 'shar':
program = 'unshar'
tmpdir = patoolib.util.tmpdir(dir=basedir)
try:
olddir = os.getcwd()
except OSError:
olddir = None
os.chdir(tmpdir)
try:
output = patoolib._handle_archive(archive, 'extract', program=program)
res = patoolib.util.run([diff, "-urN", srcfile, output])
self.assertEqual(res, 0)
finally:
if olddir:
os.chdir(olddir)
shutil.rmtree(tmpdir)
def get_filecontent(filename):
fo = open(filename)
try:
return fo.read()
finally:
fo.close()
def get_nonexisting_directory():
d = os.path.join(os.getcwd(), "foo")
while os.path.exists(d):
d += 'a'
return d

102
tests/archives/test_7z.py Normal file
View File

@ -0,0 +1,102 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest, Content
from .. import needs_program, needs_codec
class Test7z (ArchiveTest):
program = '7z'
@needs_program(program)
def test_7z (self):
self.archive_commands('t .7z')
self.archive_commands('t.zip')
self.archive_list('t.txt.gz')
self.archive_list('t.txt.bz2')
self.archive_list('t.jar')
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')
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')
self.archive_extract('t.rpm', check=None)
self.archive_extract('t.deb', check=None)
self.archive_test('t.txt.gz')
self.archive_test('t.txt.bz2')
self.archive_test('t.jar')
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(program, 'rar')
def test_7z_rar (self):
# only succeeds with the rar module for 7z installed
self.archive_list('t.rar')
self.archive_extract('t.rar')
self.archive_test('t.rar')
@needs_program('file')
@needs_program(program)
def test_7z_file (self):
self.archive_commands('t.7z.foo', skip_create=True)
self.archive_commands('t.zip.foo', skip_create=True)
self.archive_list('t.txt.gz.foo')
self.archive_list('t.txt.bz2.foo')
self.archive_list('t.jar.foo')
self.archive_list('t.txt.Z.foo')
self.archive_list('t.cab.foo')
self.archive_list('t.arj.foo')
self.archive_list('t.cpio.foo')
self.archive_list('t.rpm.foo')
self.archive_list('t.deb.foo')
self.archive_extract('t.txt.gz.foo', check=None)
self.archive_extract('t.txt.bz2.foo', check=Content.Singlefile)
self.archive_extract('t.jar.foo', check=None)
self.archive_extract('t.txt.Z.foo', check=Content.Singlefile)
self.archive_extract('t.cab.foo')
self.archive_extract('t.arj.foo')
self.archive_extract('t.cpio.foo')
self.archive_extract('t.rpm.foo', check=None)
self.archive_extract('t.deb.foo', check=None)
self.archive_test('t.txt.gz.foo')
self.archive_test('t.txt.bz2.foo')
self.archive_test('t.jar.foo')
self.archive_test('t.txt.Z.foo')
self.archive_test('t.cab.foo')
self.archive_test('t.arj.foo')
self.archive_test('t.cpio.foo')
self.archive_test('t.rpm.foo')
self.archive_test('t.deb.foo')
@needs_program('file')
@needs_codec(program, 'rar')
def test_7z_rar_file (self):
# only succeeds with the rar module for 7z installed
self.archive_list('t.rar.foo')
self.archive_extract('t.rar.foo')
self.archive_test('t.rar.foo')

View File

@ -0,0 +1,88 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest, Content
from .. import needs_program
class Test7za (ArchiveTest):
program = '7za'
@needs_program(program)
def test_p7azip (self):
# unsupported actions of the 7za standalone program are commented out
self.archive_commands('t .7z')
self.archive_commands('t.zip')
self.archive_list('t.txt.gz')
self.archive_list('t.txt.bz2')
self.archive_list('t.jar')
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')
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')
#self.archive_extract('t.rpm', check=None)
#self.archive_extract('t.deb', check=None)
self.archive_test('t.txt.gz')
self.archive_test('t.txt.bz2')
self.archive_test('t.jar')
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('file')
@needs_program(program)
def test_7za_file (self):
self.archive_commands('t.7z.foo', skip_create=True)
self.archive_commands('t.zip.foo', skip_create=True)
self.archive_list('t.txt.gz.foo')
self.archive_list('t.txt.bz2.foo')
self.archive_list('t.jar.foo')
self.archive_list('t.txt.Z.foo')
self.archive_list('t.cab.foo')
#self.archive_list('t.arj.foo')
#self.archive_list('t.cpio.foo')
self.archive_list('t.rpm.foo')
#self.archive_list('t.deb.foo')
self.archive_extract('t.txt.gz.foo', check=None)
self.archive_extract('t.txt.bz2.foo', check=Content.Singlefile)
self.archive_extract('t.jar.foo', check=None)
self.archive_extract('t.txt.Z.foo', check=Content.Singlefile)
self.archive_extract('t.cab.foo')
#self.archive_extract('t.arj.foo')
#self.archive_extract('t.cpio.foo')
#self.archive_extract('t.rpm.foo', check=None)
#self.archive_extract('t.deb.foo', check=None)
self.archive_test('t.txt.gz.foo')
self.archive_test('t.txt.bz2.foo')
self.archive_test('t.jar.foo')
self.archive_test('t.txt.Z.foo')
self.archive_test('t.cab.foo')
#self.archive_test('t.arj.foo')
#self.archive_test('t.cpio.foo')
#self.archive_test('t.rpm.foo')
#self.archive_test('t.deb.foo')

33
tests/archives/test_ar.py Normal file
View File

@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program, needs_os
class TestAr (ArchiveTest):
program = 'ar'
@needs_os('posix')
@needs_program(program)
def test_ar(self):
self.archive_commands('t.txt.a', singlefile=True)
@needs_os('posix')
@needs_program('file')
@needs_program(program)
def test_ar_file(self):
self.archive_commands('t.txt.a.foo', skip_create=True, check=None)

View File

@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestArc(ArchiveTest):
program = 'arc'
@needs_program(program)
def test_arc(self):
self.archive_commands('t.arc', singlefile=True)
@needs_program('file')
@needs_program(program)
def test_arc_file(self):
self.archive_commands('t.arc.foo', skip_create=True)

View File

@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestArj (ArchiveTest):
program = 'arj'
@needs_program(program)
def test_arj(self):
self.archive_commands('t.arj')
@needs_program('file')
@needs_program(program)
def test_arj_file(self):
self.archive_commands('t.arj.foo', skip_create=True)

View File

@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestBsdcpio (ArchiveTest):
program = 'bsdcpio'
@needs_program(program)
def test_bsdcpio(self):
self.archive_commands('t.cpio')
@needs_program('file')
@needs_program(program)
def test_bsdcpio_file(self):
self.archive_commands('t.cpio.foo', skip_create=True)

View File

@ -0,0 +1,99 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program, needs_codec
class TestBsdtar (ArchiveTest):
program = 'bsdtar'
@needs_program(program)
def test_bsdtar (self):
self.archive_commands('t.tar')
@needs_codec(program, 'gzip')
def test_bsdtar_gz (self):
self.archive_commands('t.tar.gz')
self.archive_commands('t.tgz')
@needs_program(program)
@needs_program('compress')
def test_bsdtar_z (self):
self.archive_commands('t.tar.Z')
self.archive_commands('t.taz')
@needs_codec(program, 'bzip2')
def test_bsdtar_bz2 (self):
self.archive_commands('t.tar.bz2')
self.archive_commands('t.tbz2')
@needs_codec(program, 'lzma')
def test_bsdtar_lzma (self):
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(program)
@needs_program('lzip')
def test_bsdtar_lzip (self):
self.archive_commands('t.tar.lz')
@needs_codec(program, 'xz')
def test_bsdtar_xz (self):
self.archive_commands('t.tar.xz')
@needs_program('file')
@needs_program(program)
def test_bsdtar_file (self):
self.archive_commands('t.tar.foo', skip_create=True)
@needs_program('file')
@needs_codec(program, 'gzip')
def test_bsdtar_gz_file (self):
self.archive_commands('t.tar.gz.foo', skip_create=True)
self.archive_commands('t.tgz.foo', skip_create=True)
@needs_program('file')
@needs_codec(program, 'compress')
def test_bsdtar_z_file (self):
self.archive_commands('t.tar.Z.foo', skip_create=True)
self.archive_commands('t.taz.foo', skip_create=True)
@needs_program('file')
@needs_codec(program, 'bzip2')
def test_bsdtar_bz2_file (self):
self.archive_commands('t.tar.bz2.foo', skip_create=True)
self.archive_commands('t.tbz2.foo', skip_create=True)
# file(1) does not recognize .lzma files (at least not with --uncompress)
#@needs_program('file')
#@needs_codec(program, 'lzma')
#def test_bsdtar_lzma_file (self):
# self.archive_commands('t.tar.lzma.foo', skip_create=True)
# even though clzip would support extracting .lz files, the
# file(1) --uncompress command does not use it for achive detection
@needs_program('lzip')
@needs_program('file')
@needs_codec(program, 'lzip')
def test_bsdtar_lzip_file (self):
self.archive_commands('t.tar.lz.foo', skip_create=True)
@needs_program('file')
@needs_codec(program, 'xz')
def test_bsdtar_xz_file (self):
self.archive_commands('t.tar.xz.foo', skip_create=True)

View File

@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest, Content
from .. import needs_program
class TestBzip2 (ArchiveTest):
program = 'bzip2'
@needs_program(program)
def test_bzip2 (self):
self.archive_extract('t.txt.bz2', check=Content.Singlefile)
self.archive_test('t.txt.bz2')
self.archive_create('t.txt.bz2', singlefile=True)
@needs_program('file')
@needs_program(program)
def test_bzip2_file (self):
self.archive_extract('t.txt.bz2.foo', check=Content.Singlefile)
self.archive_test('t.txt.bz2.foo')

View File

@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestCabextract (ArchiveTest):
program = 'cabextract'
@needs_program(program)
def test_cabextract (self):
self.archive_list('t.cab')
self.archive_extract('t.cab', check=None)
@needs_program('file')
@needs_program(program)
def test_cabextract_file(self):
self.archive_list('t.cab.foo')
self.archive_extract('t.cab.foo', check=None)

View File

@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest, Content
from .. import needs_program
class TestClzip (ArchiveTest):
program = 'clzip'
@needs_program(program)
def test_clzip(self):
self.archive_test('t.txt.lz')
self.archive_extract('t.txt.lz', check=Content.Singlefile)
self.archive_create('t.txt.lz', singlefile=True)
@needs_program('file')
@needs_program(program)
def test_clzip_file(self):
self.archive_test('t.txt.lz.foo')
self.archive_extract('t.txt.lz.foo', check=Content.Singlefile)

View File

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestCompress (ArchiveTest):
program = 'compress'
@needs_program(program)
def test_compress (self):
self.archive_create('t.txt.Z', singlefile=True)

View File

@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestCpio (ArchiveTest):
program = 'cpio'
@needs_program(program)
def test_cpio(self):
self.archive_commands('t.cpio')
@needs_program('file')
@needs_program(program)
def test_cpio_file(self):
self.archive_commands('t.cpio.foo', skip_create=True)

View File

@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestDpkg (ArchiveTest):
program = 'dpkg-deb'
@needs_program(program)
def test_dpkg(self):
self.archive_list('t.deb')
self.archive_extract('t.deb', check=None)
self.archive_test('t.deb')
@needs_program('file')
@needs_program(program)
def test_dpkg_file(self):
self.archive_list('t.deb.foo')
self.archive_extract('t.deb.foo', check=None)
self.archive_test('t.deb.foo')

View File

@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestFlac (ArchiveTest):
program = 'flac'
@needs_program(program)
def test_flac(self):
self.archive_extract('t.flac', check=None)
self.archive_test('t.flac')
self.archive_create('t.flac', srcfile="t.wav")
@needs_program('file')
@needs_program(program)
def test_flac_file(self):
self.archive_extract('t.flac.foo', check=None)
self.archive_test('t.flac.foo')

View File

@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest, Content
from .. import needs_program
class TestGzip (ArchiveTest):
program = 'gzip'
@needs_program(program)
def test_gzip (self):
self.archive_commands('t.txt.gz', singlefile=True)
self.archive_extract('t.txt.Z', check=Content.Singlefile)
@needs_program('file')
@needs_program(program)
def test_gzip_file(self):
self.archive_commands('t.txt.gz.foo', skip_create=True, check=None)
self.archive_extract('t.txt.Z.foo', check=Content.Singlefile)

View File

@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest, Content
from .. import needs_program
class TestLbzip2 (ArchiveTest):
program = 'lbzip2'
@needs_program(program)
def test_lbzip2 (self):
self.archive_extract('t.txt.bz2', check=Content.Singlefile)
self.archive_test('t.txt.bz2')
self.archive_create('t.txt.bz2', singlefile=True)
@needs_program('file')
@needs_program(program)
def test_lbzip2_file (self):
self.archive_extract('t.txt.bz2.foo', check=Content.Singlefile)
self.archive_test('t.txt.bz2.foo')

View File

@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestLcab (ArchiveTest):
program = 'lcab'
@needs_program(program)
@needs_program('cabextract')
def test_lcab (self):
self.archive_create('t.cab')

View File

@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestLha (ArchiveTest):
program = 'lha'
@needs_program(program)
def test_lha(self):
self.archive_commands('t.lha')
@needs_program('file')
@needs_program(program)
def test_lha_file(self):
self.archive_commands('t.lha.foo', skip_create=True)

View File

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestLhasa (ArchiveTest):
program = 'lhasa'
@needs_program(program)
def test_lhasa(self):
self.archive_extract('t.lha')

View File

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestLrzip (ArchiveTest):
program = 'lrzip'
@needs_program(program)
def test_lrzip(self):
self.archive_test('t.txt.lrz')
self.archive_extract('t.txt.lrz')
self.archive_create('t.txt.lrz', singlefile=True)
# file(1) does not recognize .lrz files
#@needs_program('file')
#@needs_program(program)
#def test_lrzip_file(self):
# self.archive_test('t.txt.lrz.foo')
# self.archive_extract('t.txt.lrz.foo')
# self.archive_create('t.txt.lrz.foo', format="lrzip", singlefile=True)

View File

@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest, Content
from .. import needs_program
class TestLzip (ArchiveTest):
program = 'lzip'
@needs_program(program)
def test_lzip(self):
self.archive_test('t.txt.lz')
self.archive_extract('t.txt.lz', check=Content.Singlefile)
self.archive_create('t.txt.lz', singlefile=True)
@needs_program('file')
@needs_program(program)
def test_lzip_file(self):
self.archive_test('t.txt.lz.foo')
self.archive_extract('t.txt.lz.foo', check=Content.Singlefile)

View File

@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest, Content
from .. import needs_program
class TestLzma (ArchiveTest):
program = 'lzma'
@needs_program(program)
def test_lzma(self):
self.archive_test('t.txt.lzma')
self.archive_extract('t.txt.lzma', check=Content.Singlefile)
self.archive_create('t.txt.lzma', singlefile=True)
# file(1) does not recognize .lzma files
#@needs_program('file')
#@needs_program(program)
#def test_lzma_file(self):
# self.archive_test('t.lzma.foo')
# self.archive_extract('t.lzma.foo')

View File

@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestLzop (ArchiveTest):
program = 'lzop'
@needs_program(program)
def test_lzop(self):
self.archive_commands('t.lzo', singlefile=True)
@needs_program('file')
@needs_program(program)
def test_lzop_file(self):
self.archive_commands('t.lzo.foo', skip_create=True)

View File

@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestMac (ArchiveTest):
program = 'mac'
@needs_program(program)
def test_mac(self):
self.archive_extract('t.ape', check=None)
self.archive_test('t.ape')
self.archive_create('t.ape', srcfile="t.wav")
@needs_program('file')
@needs_program(program)
def test_mac_file(self):
self.archive_extract('t.ape.foo', check=None)

View File

@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestNomarch(ArchiveTest):
program = 'nomarch'
@needs_program(program)
def test_nomarch(self):
self.archive_test('t.arc')
self.archive_list('t.arc')
self.archive_extract('t.arc')
@needs_program('file')
@needs_program(program)
def test_nomarch_file(self):
self.archive_test('t.arc.foo')
self.archive_list('t.arc.foo')
self.archive_extract('t.arc.foo')

View File

@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest, Content
from .. import needs_program
class TestPbzip2 (ArchiveTest):
program = 'pbzip2'
@needs_program(program)
def test_pbzip2 (self):
self.archive_extract('t.txt.bz2', check=Content.Singlefile)
self.archive_test('t.txt.bz2')
self.archive_create('t.txt.bz2', singlefile=True)
@needs_program('file')
@needs_program(program)
def test_pbzip2_file (self):
self.archive_extract('t.txt.bz2.foo', check=Content.Singlefile)
self.archive_test('t.txt.bz2.foo')

View File

@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest, Content
from .. import needs_program
class TestPdlzip (ArchiveTest):
program = 'pdlzip'
@needs_program(program)
def test_pdlzip(self):
self.archive_test('t.txt.lz')
self.archive_extract('t.txt.lz', check=Content.Singlefile)
self.archive_create('t.txt.lz', singlefile=True)
@needs_program('file')
@needs_program(program)
def test_pdlzip_file(self):
self.archive_test('t.txt.lz.foo')
self.archive_extract('t.txt.lz.foo', check=Content.Singlefile)

View File

@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestPigz (ArchiveTest):
program = 'pigz'
@needs_program(program)
def test_pigz (self):
self.archive_commands('t.txt.gz', singlefile=True)
@needs_program('file')
@needs_program(program)
def test_pigz_file (self):
self.archive_commands('t.txt.gz.foo', singlefile=True)

View File

@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest, Content
from .. import needs_program
class TestPlzip (ArchiveTest):
program = 'plzip'
@needs_program(program)
def test_plzip(self):
self.archive_test('t.txt.lz')
self.archive_extract('t.txt.lz', check=Content.Singlefile)
self.archive_create('t.txt.lz', singlefile=True)
@needs_program('file')
@needs_program(program)
def test_plzip_file(self):
self.archive_test('t.txt.lz.foo')
self.archive_extract('t.txt.lz.foo', check=Content.Singlefile)

View File

@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest, Content
from .. import needs_program
class TestPybz2 (ArchiveTest):
program = 'py_bz2'
@needs_program('bzip2')
def test_py_bz2 (self):
self.archive_extract('t.txt.bz2', check=Content.Singlefile)
# bzip2 is used to test the created archive
self.archive_create('t.txt.bz2', singlefile=True)
@needs_program('file')
def test_py_bz2_file (self):
self.archive_extract('t.txt.bz2.foo', check=Content.Singlefile)

View File

@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestPyecho (ArchiveTest):
program = 'py_echo'
def test_py_echo (self):
self.archive_list('t.txt.bz2')
self.archive_list('t.txt.Z')
self.archive_list('t.txt.lzma')
self.archive_list('t.txt.lz')
self.archive_list('t.txt.lrz')
self.archive_list('t.txt.rz')
self.archive_list('t.ape')
self.archive_list('t.shn')
self.archive_list('t.flac')
@needs_program('file')
def test_py_echo_file (self):
self.archive_list('t.txt.bz2.foo')
self.archive_list('t.txt.Z.foo')
# file(1) does not recognize .lzma files
#self.archive_list('t.lzma.foo')
self.archive_list('t.txt.lz.foo')
self.archive_list('t.txt.lrz')
self.archive_list('t.txt.rz.foo')
self.archive_list('t.ape.foo')
# file(1) does not recognize .shn files
#self.archive_list('t.shn.foo')
self.archive_list('t.flac.foo')

View File

@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest, Content
from .. import needs_program
class TestPygzip (ArchiveTest):
program = 'py_gzip'
@needs_program('gzip')
def test_py_gzip (self):
self.archive_extract('t.txt.gz', check=Content.Singlefile)
# gzip is used to test the created archive
self.archive_create('t.txt.gz', singlefile=True)
@needs_program('file')
def test_py_gzip_file (self):
self.archive_extract('t.txt.gz.foo', check=Content.Singlefile)

View File

@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestPytarfile (ArchiveTest):
program = 'py_tarfile'
def test_py_tarfile (self):
self.archive_commands('t.tar')
def test_py_tarfile_gz (self):
self.archive_commands('t.tar.gz')
self.archive_commands('t.tgz')
def test_py_tarfile_bz2 (self):
self.archive_commands('t.tar.bz2')
self.archive_commands('t.tbz2')
@needs_program('file')
def test_py_tarfile_file (self):
self.archive_commands('t.tar.foo', skip_create=True)
@needs_program('file')
def test_py_tarfile_gz_file (self):
self.archive_commands('t.tar.gz.foo', skip_create=True)
self.archive_commands('t.tgz.foo', skip_create=True)
@needs_program('file')
def test_py_tarfile_bz2_file (self):
self.archive_commands('t.tar.bz2.foo', skip_create=True)
self.archive_commands('t.tbz2.foo', skip_create=True)

View File

@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestPyzipfile (ArchiveTest):
program = 'py_zipfile'
def test_py_zipfile(self):
self.archive_commands('t.zip')
@needs_program('file')
def test_py_zipfile_file(self):
self.archive_commands('t.zip.foo', skip_create=True)

View File

@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestRar (ArchiveTest):
program = 'rar'
@needs_program(program)
def test_rar(self):
self.archive_commands('t.rar')
@needs_program('file')
@needs_program(program)
def test_rar_file(self):
self.archive_commands('t.rar.foo', skip_create=True)

View File

@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestRpm (ArchiveTest):
program = 'rpm'
@needs_program('rpm')
def test_rpm(self):
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')
@needs_program('file')
@needs_program(program)
def test_rpm_file(self):
self.archive_list('t.rpm.foo')
# 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.foo')

View File

@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestRpm2cpio (ArchiveTest):
program = 'rpm2cpio'
@needs_program(program)
@needs_program('cpio')
def test_rpm2cpio(self):
self.archive_extract('t.rpm', check=None)
@needs_program('file')
@needs_program(program)
@needs_program('cpio')
def test_rpm2cpio_file(self):
self.archive_extract('t.rpm.foo', check=None)

View File

@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestRzip (ArchiveTest):
program = 'rzip'
@needs_program(program)
def test_rzip(self):
self.archive_extract('t.txt.rz')
self.archive_create('t.txt.rz', singlefile=True)
@needs_program(program)
def test_rzip_file(self):
self.archive_extract('t.txt.rz.foo')

View File

@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestShar (ArchiveTest):
program = 'shar'
@needs_program(program)
@needs_program('unshar')
def test_shar(self):
self.archive_create('t.shar', singlefile=True)

View File

@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestShorten (ArchiveTest):
program = 'shorten'
@needs_program(program)
def test_shorten(self):
self.archive_extract('t.shn', check=None)
self.archive_create('t.shn', srcfile="t.wav")
# file(1) does not recognize .shn files
#@needs_program('file')
#@needs_program(program)
#def test_shorten_file(self):
# self.archive_extract('t.shn.foo', check=None)

View File

@ -0,0 +1,94 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program, needs_codec
class TestStar (ArchiveTest):
program = 'star'
@needs_program(program)
def test_star (self):
self.archive_commands('t.tar')
@needs_codec(program, 'gzip')
def test_star_gz (self):
self.archive_commands('t.tar.gz')
self.archive_commands('t.tgz')
@needs_program(program)
@needs_program('compress')
def test_star_z (self):
self.archive_commands('t.tar.Z')
self.archive_commands('t.taz')
@needs_codec(program, 'bzip2')
def test_star_bz2 (self):
self.archive_commands('t.tar.bz2')
self.archive_commands('t.tbz2')
@needs_codec(program, 'lzma')
def test_star_lzma (self):
self.archive_commands('t.tar.lzma')
@needs_program(program)
@needs_program('lzip')
def test_star_lzip (self):
self.archive_commands('t.tar.lz')
@needs_codec(program, 'xz')
def test_star_xz (self):
self.archive_commands('t.tar.xz')
@needs_program('file')
@needs_program(program)
def test_star_file (self):
self.archive_commands('t.tar.foo', skip_create=True)
@needs_program('file')
@needs_codec(program, 'gzip')
def test_star_gz_file (self):
self.archive_commands('t.tar.gz.foo', skip_create=True)
self.archive_commands('t.tgz.foo', skip_create=True)
@needs_program('file')
@needs_codec(program, 'compress')
def test_star_z_file (self):
self.archive_commands('t.tar.Z.foo', skip_create=True)
self.archive_commands('t.taz.foo', skip_create=True)
@needs_program('file')
@needs_codec(program, 'bzip2')
def test_star_bz2_file (self):
self.archive_commands('t.tar.bz2.foo', skip_create=True)
self.archive_commands('t.tbz2.foo', skip_create=True)
# file(1) does not recognize .lzma files
#@needs_program('file')
#@needs_codec(program, 'lzma')
#def test_star_lzma_file (self):
# self.archive_commands('t.tar.lzma.foo', skip_create=True)
@needs_program('file')
@needs_codec(program, 'lzip')
def test_star_lzip_file (self):
self.archive_commands('t.tar.lz.foo', skip_create=True)
@needs_program('file')
@needs_codec(program, 'xz')
def test_star_xz_file (self):
self.archive_commands('t.tar.xz.foo', skip_create=True)

View File

@ -0,0 +1,99 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program, needs_codec
class TestTar (ArchiveTest):
program = 'tar'
@needs_program(program)
def test_tar (self):
self.archive_commands('t.tar')
@needs_codec(program, 'gzip')
def test_tar_gz (self):
self.archive_commands('t.tar.gz')
self.archive_commands('t.tgz')
@needs_program(program)
@needs_program('compress')
def test_tar_z (self):
self.archive_commands('t.tar.Z')
self.archive_commands('t.taz')
@needs_codec(program, 'bzip2')
def test_tar_bz2 (self):
self.archive_commands('t.tar.bz2')
self.archive_commands('t.tbz2')
@needs_codec(program, 'lzma')
def test_tar_lzma (self):
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(program)
@needs_program('lzip')
def test_tar_lzip (self):
self.archive_commands('t.tar.lz')
@needs_codec(program, 'xz')
def test_tar_xz (self):
self.archive_commands('t.tar.xz')
@needs_program('file')
@needs_program(program)
def test_tar_file (self):
self.archive_commands('t.tar.foo', skip_create=True)
@needs_program('file')
@needs_codec(program, 'gzip')
def test_tar_gz_file (self):
self.archive_commands('t.tar.gz.foo', skip_create=True)
self.archive_commands('t.tgz.foo', skip_create=True)
@needs_program('file')
@needs_codec(program, 'compress')
def test_tar_z_file (self):
self.archive_commands('t.tar.Z.foo', skip_create=True)
self.archive_commands('t.taz.foo', skip_create=True)
@needs_program('file')
@needs_codec(program, 'bzip2')
def test_tar_bz2_file (self):
self.archive_commands('t.tar.bz2.foo', skip_create=True)
self.archive_commands('t.tbz2.foo', skip_create=True)
# file(1) does not recognize .lzma files (at least not with --uncompress)
#@needs_program('file')
#@needs_codec(program, 'lzma')
#def test_tar_lzma_file (self):
# self.archive_commands('t.tar.lzma.foo', format="tar", compression="lzma")
# even though clzip would support extracting .lz files, the
# file(1) --uncompress command does not use it for achive detection
@needs_program('lzip')
@needs_program('file')
@needs_codec(program, 'lzip')
def test_tar_lzip_file (self):
self.archive_commands('t.tar.lz.foo', skip_create=True)
@needs_program('file')
@needs_codec(program, 'xz')
def test_tar_xz_file (self):
self.archive_commands('t.tar.xz.foo', skip_create=True)

View File

@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestUnace (ArchiveTest):
program = 'unace'
@needs_program(program)
def test_unace(self):
self.archive_list('t.ace')
self.archive_test('t.ace')
self.archive_extract('t.ace')
@needs_program('file')
@needs_program(program)
def test_unace_file(self):
self.archive_list('t.ace.foo')
self.archive_test('t.ace.foo')
self.archive_extract('t.ace.foo')

View File

@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestUnadf (ArchiveTest):
program = 'unadf'
@needs_program(program)
def test_unadf(self):
self.archive_extract('t.adf', check=None)
self.archive_list('t.adf')
self.archive_test('t.adf')
@needs_program('file')
@needs_program(program)
def test_unadf_file(self):
self.archive_extract('t.adf.foo', check=None)
self.archive_test('t.adf.foo')
self.archive_list('t.adf.foo')

View File

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestUnalz (ArchiveTest):
program = 'unalz'
@needs_program(program)
def test_unalz(self):
self.archive_test('t.alz')
self.archive_list('t.alz')
self.archive_extract('t.alz')
# file(1) does not recognize .alz files
#@needs_program('file')
#@needs_program(program)
#def test_unalz_file(self):
# self.archive_test('t.alz.foo')
# self.archive_list('t.alz.foo')
# self.archive_extract('t.alz.foo')

View File

@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest, Content
from .. import needs_program
class TestUncompressReal (ArchiveTest):
program = 'uncompress.real'
@needs_program(program)
def test_uncompress (self):
self.archive_extract('t.txt.Z', check=Content.Singlefile)
@needs_program('file')
@needs_program(program)
def test_uncompress_file (self):
self.archive_extract('t.txt.Z.foo', check=Content.Singlefile)

View File

@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestUnrar (ArchiveTest):
program = 'unrar'
@needs_program(program)
def test_unrar(self):
self.archive_list('t.rar')
self.archive_extract('t.rar')
@needs_program('file')
@needs_program(program)
def test_unrar_file(self):
self.archive_list('t.rar.foo')
self.archive_extract('t.rar.foo')

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestUnshar (ArchiveTest):
program = 'unshar'
@needs_program(program)
def test_unshar(self):
self.archive_extract('t.shar', check=None)

View File

@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestUnzip (ArchiveTest):
program = 'unzip'
@needs_program(program)
def test_unzip (self):
self.archive_extract('t.zip', check=None)
self.archive_list('t.zip')
self.archive_test('t.zip')
self.archive_extract('t.jar', check=None)
self.archive_list('t.jar')
self.archive_test('t.jar')
@needs_program('file')
@needs_program(program)
def test_unzip_file (self):
self.archive_extract('t.zip.foo', check=None)
self.archive_list('t.zip.foo')
self.archive_test('t.zip.foo')
self.archive_extract('t.jar.foo', check=None)
self.archive_list('t.jar.foo')
self.archive_test('t.jar.foo')

View File

@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestXdms (ArchiveTest):
program = 'xdms'
@needs_program(program)
def test_xdms(self):
self.archive_extract('t.dms', check=None)
self.archive_list('t.dms')
self.archive_test('t.dms')
# xdms(1) cannot handle files without '.dms' extension
#@needs_program(program)
#def test_xdms_file(self):
# self.archive_extract('t.dms.foo')
# self.archive_test('t.dms.foo')
# self.archive_list('t.dms.foo')

32
tests/archives/test_xz.py Normal file
View File

@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest, Content
from .. import needs_program
class TestXz (ArchiveTest):
program = 'xz'
@needs_program(program)
def test_xz(self):
self.archive_commands('t.txt.xz', singlefile=True)
@needs_program('file')
@needs_program(program)
def test_xz_file(self):
self.archive_test('t.txt.xz.foo')
self.archive_extract('t.txt.xz.foo', check=Content.Singlefile)

View File

@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestZip (ArchiveTest):
program = 'zip'
@needs_program(program)
def test_zip (self):
self.archive_create('t.zip')
@needs_program('file')
@needs_program(program)
def test_zip_file (self):
self.archive_commands('t.zip.foo', skip_create=True)

View File

@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest
from .. import needs_program
class TestZoo (ArchiveTest):
program = 'zoo'
@needs_program(program)
def test_zoo(self):
# XXX test failure - zoo cannot read its own files back :-(
self.archive_commands('t.zoo', singlefile=True)
# XXX test failure
#@needs_program(program)
#def test_zoo_file(self):
# self.archive_commands('t.zoo.foo', skip_create=True)

View File

@ -1,529 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest, needs_os, needs_program, needs_codec, Content
class TestArchives (ArchiveTest):
@needs_program('tar')
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')
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')
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')
# even though clzip would support extracting .lz files, the
# file(1) --uncompress command does not use it for achive detection
@needs_program('tar')
@needs_program('lzip')
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')
@needs_program('star')
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')
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')
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')
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')
@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')
def test_bzip2 (self):
self.program = 'bzip2'
self.archive_extract('t.txt.bz2', check=Content.Singlefile)
self.archive_test('t.txt.bz2')
self.archive_create('t.txt.bz2', singlefile=True)
@needs_program('bzip2')
def test_py_bz2 (self):
self.program = 'py_bz2'
self.archive_extract('t.txt.bz2', check=Content.Singlefile)
# bzip2 is used to test the created archive
self.archive_create('t.txt.bz2', singlefile=True)
@needs_program('pbzip2')
def test_pbzip2 (self):
self.program = 'pbzip2'
self.archive_extract('t.txt.bz2', check=Content.Singlefile)
self.archive_test('t.txt.bz2')
self.archive_create('t.txt.bz2', singlefile=True)
@needs_program('lbzip2')
def test_lbzip2 (self):
self.program = 'lbzip2'
self.archive_extract('t.txt.bz2', check=Content.Singlefile)
self.archive_test('t.txt.bz2')
self.archive_create('t.txt.bz2', singlefile=True)
def test_py_echo (self):
self.program = 'py_echo'
self.archive_list('t.txt.bz2')
self.archive_list('t.txt.Z')
self.archive_list('t.txt.lzma')
self.archive_list('t.txt.lz')
self.archive_list('t.txt.lrz')
self.archive_list('t.txt.rz')
self.archive_list('t.ape')
self.archive_list('t.shn')
self.archive_list('t.flac')
@needs_program('unzip')
def test_unzip (self):
self.program = 'unzip'
self.archive_extract('t.zip', check=None)
self.archive_list('t.zip')
self.archive_test('t.zip')
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')
def test_gzip (self):
self.program = 'gzip'
self.archive_commands('t.txt.gz', singlefile=True)
self.archive_extract('t.txt.Z', check=Content.Singlefile)
@needs_program('gzip')
def test_py_gzip (self):
self.program = 'py_gzip'
self.archive_extract('t.txt.gz', check=Content.Singlefile)
# gzip is used to test the created archive
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')
def test_uncompress (self):
self.program = 'uncompress.real'
self.archive_extract('t.txt.Z', check=Content.Singlefile)
@needs_program('compress')
def test_compress (self):
self.program = 'compress'
self.archive_create('t.txt.Z', singlefile=True)
@needs_program('7z')
def test_p7zip (self):
self.program = '7z'
self.archive_commands('t .7z')
self.archive_commands('t.zip')
self.archive_list('t.txt.gz')
self.archive_list('t.txt.bz2')
self.archive_list('t.jar')
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')
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')
self.archive_extract('t.rpm', check=None)
self.archive_extract('t.deb', check=None)
self.archive_test('t.txt.gz')
self.archive_test('t.txt.bz2')
self.archive_test('t.jar')
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')
self.archive_list('t.txt.gz')
self.archive_list('t.txt.bz2')
self.archive_list('t.jar')
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')
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')
#self.archive_extract('t.rpm', check=None)
#self.archive_extract('t.deb', check=None)
self.archive_test('t.txt.gz')
self.archive_test('t.txt.bz2')
self.archive_test('t.jar')
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')
def test_unrar (self):
self.program = 'unrar'
self.archive_list('t.rar')
self.archive_extract('t.rar')
@needs_program('rar')
def test_rar (self):
self.program = 'rar'
self.archive_commands('t.rar')
@needs_program('cabextract')
def test_cabextract (self):
self.program = 'cabextract'
self.archive_list('t.cab')
self.archive_extract('t.cab', check=None)
@needs_program('lcab')
@needs_program('cabextract')
def test_lcab (self):
self.program = 'lcab'
self.archive_create('t.cab')
@needs_program('arj')
def test_arj (self):
self.program = 'arj'
self.archive_commands('t.arj')
@needs_os('posix')
@needs_program('ar')
def test_ar (self):
self.program = 'ar'
self.archive_commands('t.txt.a', singlefile=True)
@needs_program('cpio')
def test_cpio (self):
self.program = 'cpio'
self.archive_commands('t.cpio')
@needs_program('bsdcpio')
def test_bsdcpio (self):
self.program = 'bsdcpio'
self.archive_commands('t.cpio')
@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')
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')
@needs_program('rpm2cpio')
@needs_program('cpio')
def test_rpm_extract (self):
self.program = 'rpm2cpio'
self.archive_extract('t.rpm', check=None)
@needs_program('dpkg-deb')
def test_dpkg (self):
self.program = 'dpkg'
self.archive_list('t.deb')
self.archive_extract('t.deb', check=None)
self.archive_test('t.deb')
@needs_program('lzop')
def test_lzop (self):
self.program = 'lzop'
self.archive_commands('t.lzo', singlefile=True)
@needs_program('lzma')
def test_lzma (self):
self.program = 'lzma'
self.archive_test('t.txt.lzma')
self.archive_extract('t.txt.lzma', check=Content.Singlefile)
self.archive_create('t.txt.lzma', singlefile=True)
@needs_program('lzip')
def test_lzip (self):
self.program = 'lzip'
self.archive_test('t.txt.lz')
self.archive_extract('t.txt.lz', check=Content.Singlefile)
self.archive_create('t.txt.lz', singlefile=True)
@needs_program('clzip')
def test_clzip (self):
self.program = 'clzip'
self.archive_test('t.txt.lz')
self.archive_extract('t.txt.lz', check=Content.Singlefile)
self.archive_create('t.txt.lz', singlefile=True)
@needs_program('plzip')
def test_plzip (self):
self.program = 'plzip'
self.archive_test('t.txt.lz')
self.archive_extract('t.txt.lz', check=Content.Singlefile)
self.archive_create('t.txt.lz', singlefile=True)
@needs_program('pdlzip')
def test_pdlzip (self):
self.program = 'pdlzip'
self.archive_test('t.txt.lz')
self.archive_extract('t.txt.lz', check=Content.Singlefile)
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')
def test_xz (self):
self.program = 'xz'
self.archive_commands('t.txt.xz', singlefile=True)
@needs_program('lha')
def test_lha (self):
self.program = 'lha'
self.archive_commands('t.lha')
@needs_program('lhasa')
def test_lhasa (self):
self.program = 'lhasa'
self.archive_extract('t.lha')
@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')
@needs_program('lrzip')
def test_lrzip (self):
self.program = 'lrzip'
self.archive_test('t.txt.lrz')
self.archive_extract('t.txt.lrz')
self.archive_create('t.txt.lrz', singlefile=True)
@needs_program('rzip')
def test_rzip (self):
self.program = 'rzip'
self.archive_extract('t.txt.rz')
self.archive_create('t.txt.rz', singlefile=True)
@needs_program('zoo')
def test_zoo (self):
self.program = 'zoo'
# XXX test failure - zoo cannot read its own files back :-(
#self.archive_commands('t.zoo', singlefile=True)
@needs_program('xdms')
def test_xdms (self):
self.program = 'xdms'
self.archive_extract('t.dms', check=None)
self.archive_list('t.dms')
self.archive_test('t.dms')
@needs_program('unadf')
def test_unadf (self):
self.program = 'unadf'
self.archive_extract('t.adf', check=None)
self.archive_list('t.adf')
self.archive_test('t.adf')
@needs_program('mac')
def test_mac (self):
self.program = 'mac'
self.archive_extract('t.ape', check=None)
self.archive_test('t.ape')
self.archive_create('t.ape', srcfile="t.wav")
@needs_program('shorten')
def test_shorten (self):
self.program = 'shorten'
self.archive_extract('t.shn', check=None)
self.archive_create('t.shn', srcfile="t.wav")
@needs_program('flac')
def test_flac (self):
self.program = 'flac'
self.archive_extract('t.flac', check=None)
self.archive_test('t.flac')
self.archive_create('t.flac', srcfile="t.wav")
@needs_program('shar')
@needs_program('unshar')
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)

View File

@ -1,540 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Bastian Kleineidam
#
# 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/>.
from . import ArchiveTest, needs_os, needs_program, needs_codec, Content
class TestArchives (ArchiveTest):
@needs_program('file')
@needs_program('tar')
def test_tar_file (self):
self.program = 'tar'
self.archive_commands('t.tar.foo', skip_create=True)
@needs_program('file')
@needs_codec('tar', 'gzip')
def test_tar_gz_file (self):
self.program = 'tar'
self.archive_commands('t.tar.gz.foo', skip_create=True)
self.archive_commands('t.tgz.foo', skip_create=True)
@needs_program('file')
@needs_codec('tar', 'compress')
def test_tar_z (self):
self.program = 'tar'
self.archive_commands('t.tar.Z.foo', skip_create=True)
self.archive_commands('t.taz.foo', skip_create=True)
@needs_program('file')
@needs_codec('tar', 'bzip2')
def test_tar_bz2 (self):
self.program = 'tar'
self.archive_commands('t.tar.bz2.foo', skip_create=True)
self.archive_commands('t.tbz2.foo', skip_create=True)
# file(1) does not recognize .lzma files (at least not with --uncompress)
#@needs_program('file')
#@needs_codec('tar', 'lzma')
#def test_tar_lzma (self):
# self.program = 'tar'
# self.archive_commands('t.tar.lzma.foo', format="tar", compression="lzma")
# even though clzip would support extracting .lz files, the
# file(1) --uncompress command does not use it for achive detection
@needs_program('lzip')
@needs_program('file')
@needs_codec('tar', 'lzip')
def test_tar_lzip (self):
self.program = 'tar'
self.archive_commands('t.tar.lz.foo', skip_create=True)
@needs_program('file')
@needs_codec('tar', 'xz')
def test_tar_xz (self):
self.program = 'tar'
self.archive_commands('t.tar.xz.foo', skip_create=True)
@needs_program('file')
@needs_program('bsdtar')
def test_bsdtar_file (self):
self.program = 'bsdtar'
self.archive_commands('t.tar.foo', skip_create=True)
@needs_program('file')
@needs_codec('bsdtar', 'gzip')
def test_bsdtar_gz_file (self):
self.program = 'bsdtar'
self.archive_commands('t.tar.gz.foo', skip_create=True)
self.archive_commands('t.tgz.foo', skip_create=True)
@needs_program('file')
@needs_codec('bsdtar', 'compress')
def test_bsdtar_z (self):
self.program = 'bsdtar'
self.archive_commands('t.tar.Z.foo', skip_create=True)
self.archive_commands('t.taz.foo', skip_create=True)
@needs_program('file')
@needs_codec('bsdtar', 'bzip2')
def test_bsdtar_bz2 (self):
self.program = 'bsdtar'
self.archive_commands('t.tar.bz2.foo', skip_create=True)
self.archive_commands('t.tbz2.foo', skip_create=True)
# file(1) does not recognize .lzma files (at least not with --uncompress)
#@needs_program('file')
#@needs_codec('bsdtar', 'lzma')
#def test_bsdtar_lzma (self):
# self.program = 'bsdtar'
# self.archive_commands('t.tar.lzma.foo', skip_create=True)
# even though clzip would support extracting .lz files, the
# file(1) --uncompress command does not use it for achive detection
@needs_program('lzip')
@needs_program('file')
@needs_codec('bsdtar', 'lzip')
def test_bsdtar_lzip (self):
self.program = 'bsdtar'
self.archive_commands('t.tar.lz.foo', skip_create=True)
@needs_program('file')
@needs_codec('bsdtar', 'xz')
def test_bsdtar_xz (self):
self.program = 'bsdtar'
self.archive_commands('t.tar.xz.foo', skip_create=True)
@needs_program('file')
@needs_program('star')
def test_star (self):
self.program = 'star'
self.archive_commands('t.tar.foo', skip_create=True)
@needs_program('file')
@needs_codec('star', 'gzip')
def test_star_gz (self):
self.program = 'star'
self.archive_commands('t.tar.gz.foo', skip_create=True)
self.archive_commands('t.tgz.foo', skip_create=True)
@needs_program('file')
@needs_codec('star', 'compress')
def test_star_z (self):
self.program = 'star'
self.archive_commands('t.tar.Z.foo', skip_create=True)
self.archive_commands('t.taz.foo', skip_create=True)
@needs_program('file')
@needs_codec('star', 'bzip2')
def test_star_bz2 (self):
self.program = 'star'
self.archive_commands('t.tar.bz2.foo', skip_create=True)
self.archive_commands('t.tbz2.foo', skip_create=True)
# file(1) does not recognize .lzma files
#@needs_program('file')
#@needs_codec('star', 'lzma')
#def test_star_lzma (self):
# self.program = 'star'
# self.archive_commands('t.tar.lzma.foo', skip_create=True)
@needs_program('file')
@needs_codec('star', 'lzip')
def test_star_lzip (self):
self.program = 'star'
self.archive_commands('t.tar.lz.foo', skip_create=True)
@needs_program('file')
@needs_codec('star', 'xz')
def test_star_xz (self):
self.program = 'star'
self.archive_commands('t.tar.xz.foo', skip_create=True)
@needs_program('file')
def test_py_tarfile_file (self):
self.program = 'py_tarfile'
self.archive_commands('t.tar.foo', skip_create=True)
@needs_program('file')
def test_py_tarfile_gz_file (self):
self.program = 'py_tarfile'
self.archive_commands('t.tar.gz.foo', skip_create=True)
self.archive_commands('t.tgz.foo', skip_create=True)
@needs_program('file')
def test_py_tarfile_bz2 (self):
self.program = 'py_tarfile'
self.archive_commands('t.tar.bz2.foo', skip_create=True)
self.archive_commands('t.tbz2.foo', skip_create=True)
@needs_program('file')
@needs_program('bzip2')
def test_bzip2 (self):
self.program = 'bzip2'
self.archive_extract('t.txt.bz2.foo', check=Content.Singlefile)
self.archive_test('t.txt.bz2.foo')
@needs_program('file')
def test_py_bz2 (self):
self.program = 'py_bz2'
self.archive_extract('t.txt.bz2.foo', check=Content.Singlefile)
@needs_program('file')
@needs_program('pbzip2')
def test_pbzip2 (self):
self.program = 'pbzip2'
self.archive_extract('t.txt.bz2.foo', check=Content.Singlefile)
self.archive_test('t.txt.bz2.foo')
@needs_program('file')
@needs_program('lbzip2')
def test_lbzip2 (self):
self.program = 'lbzip2'
self.archive_extract('t.txt.bz2.foo', check=Content.Singlefile)
self.archive_test('t.txt.bz2.foo')
@needs_program('file')
def test_py_echo (self):
self.program = 'py_echo'
self.archive_list('t.txt.bz2.foo')
self.archive_list('t.txt.Z.foo')
# file(1) does not recognize .lzma files
#self.archive_list('t.lzma.foo')
self.archive_list('t.txt.lz.foo')
self.archive_list('t.txt.lrz')
self.archive_list('t.txt.rz.foo')
self.archive_list('t.ape.foo')
# file(1) does not recognize .shn files
#self.archive_list('t.shn.foo')
self.archive_list('t.flac.foo')
@needs_program('file')
@needs_program('unzip')
def test_unzip (self):
self.program = 'unzip'
self.archive_extract('t.zip.foo', check=None)
self.archive_list('t.zip.foo')
self.archive_test('t.zip.foo')
self.archive_extract('t.jar.foo', check=None)
self.archive_list('t.jar.foo')
self.archive_test('t.jar.foo')
@needs_program('file')
def test_py_zipfile (self):
self.program = 'py_zipfile'
self.archive_commands('t.zip.foo', skip_create=True)
@needs_program('file')
@needs_program('gzip')
def test_gzip (self):
self.program = 'gzip'
self.archive_commands('t.txt.gz.foo', skip_create=True, check=None)
self.archive_extract('t.txt.Z.foo', check=Content.Singlefile)
@needs_program('file')
def test_py_gzip (self):
self.program = 'py_gzip'
self.archive_extract('t.txt.gz.foo', check=Content.Singlefile)
@needs_program('file')
@needs_program('uncompress.real')
def test_uncompress (self):
self.program = 'uncompress.real'
self.archive_extract('t.txt.Z.foo', check=Content.Singlefile)
@needs_program('file')
@needs_program('7z')
def test_p7zip_file (self):
self.program = '7z'
self.archive_commands('t.7z.foo', skip_create=True)
self.archive_commands('t.zip.foo', skip_create=True)
self.archive_list('t.txt.gz.foo')
self.archive_list('t.txt.bz2.foo')
self.archive_list('t.jar.foo')
self.archive_list('t.txt.Z.foo')
self.archive_list('t.cab.foo')
self.archive_list('t.arj.foo')
self.archive_list('t.cpio.foo')
self.archive_list('t.rpm.foo')
self.archive_list('t.deb.foo')
self.archive_extract('t.txt.gz.foo', check=None)
self.archive_extract('t.txt.bz2.foo', check=Content.Singlefile)
self.archive_extract('t.jar.foo', check=None)
self.archive_extract('t.txt.Z.foo', check=Content.Singlefile)
self.archive_extract('t.cab.foo')
self.archive_extract('t.arj.foo')
self.archive_extract('t.cpio.foo')
self.archive_extract('t.rpm.foo', check=None)
self.archive_extract('t.deb.foo', check=None)
self.archive_test('t.txt.gz.foo')
self.archive_test('t.txt.bz2.foo')
self.archive_test('t.jar.foo')
self.archive_test('t.txt.Z.foo')
self.archive_test('t.cab.foo')
self.archive_test('t.arj.foo')
self.archive_test('t.cpio.foo')
self.archive_test('t.rpm.foo')
self.archive_test('t.deb.foo')
@needs_program('file')
@needs_program('7za')
def test_p7azip_file (self):
self.program = '7za'
self.archive_commands('t.7z.foo', skip_create=True)
self.archive_commands('t.zip.foo', skip_create=True)
self.archive_list('t.txt.gz.foo')
self.archive_list('t.txt.bz2.foo')
self.archive_list('t.jar.foo')
self.archive_list('t.txt.Z.foo')
self.archive_list('t.cab.foo')
#self.archive_list('t.arj.foo')
#self.archive_list('t.cpio.foo')
self.archive_list('t.rpm.foo')
#self.archive_list('t.deb.foo')
self.archive_extract('t.txt.gz.foo', check=None)
self.archive_extract('t.txt.bz2.foo', check=Content.Singlefile)
self.archive_extract('t.jar.foo', check=None)
self.archive_extract('t.txt.Z.foo', check=Content.Singlefile)
self.archive_extract('t.cab.foo')
#self.archive_extract('t.arj.foo')
#self.archive_extract('t.cpio.foo')
#self.archive_extract('t.rpm.foo', check=None)
#self.archive_extract('t.deb.foo', check=None)
self.archive_test('t.txt.gz.foo')
self.archive_test('t.txt.bz2.foo')
self.archive_test('t.jar.foo')
self.archive_test('t.txt.Z.foo')
self.archive_test('t.cab.foo')
#self.archive_test('t.arj.foo')
#self.archive_test('t.cpio.foo')
#self.archive_test('t.rpm.foo')
#self.archive_test('t.deb.foo')
@needs_program('file')
@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.foo')
self.archive_extract('t.rar.foo')
self.archive_test('t.rar.foo')
@needs_program('file')
@needs_program('unrar')
def test_unrar (self):
self.program = 'unrar'
self.archive_list('t.rar.foo')
self.archive_extract('t.rar.foo')
@needs_program('file')
@needs_program('rar')
def test_rar (self):
self.program = 'rar'
self.archive_commands('t.rar.foo', skip_create=True)
@needs_program('file')
@needs_program('cabextract')
def test_cabextract (self):
self.program = 'cabextract'
self.archive_list('t.cab.foo')
self.archive_extract('t.cab.foo', check=None)
@needs_program('file')
@needs_program('arj')
def test_arj (self):
self.program = 'arj'
self.archive_commands('t.arj.foo', skip_create=True)
@needs_os('posix')
@needs_program('file')
@needs_program('ar')
def test_ar (self):
self.program = 'ar'
self.archive_commands('t.txt.a.foo', skip_create=True, check=None)
@needs_program('file')
@needs_program('cpio')
def test_cpio (self):
self.program = 'cpio'
self.archive_commands('t.cpio.foo', skip_create=True)
@needs_program('file')
@needs_program('bsdcpio')
def test_bsdcpio (self):
self.program = 'bsdcpio'
self.archive_commands('t.cpio.foo', skip_create=True)
@needs_program('file')
@needs_program('unace')
def test_unace (self):
self.program = 'unace'
self.archive_list('t.ace.foo')
self.archive_test('t.ace.foo')
self.archive_extract('t.ace.foo')
@needs_program('file')
@needs_program('rpm')
def test_rpm (self):
self.program = 'rpm'
self.archive_list('t.rpm.foo')
# 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.foo')
@needs_program('file')
@needs_program('rpm2cpio')
@needs_program('cpio')
def test_rpm_extract (self):
self.program = 'rpm2cpio'
self.archive_extract('t.rpm.foo', check=None)
@needs_program('file')
@needs_program('dpkg-deb')
def test_dpkg (self):
self.program = 'dpkg'
self.archive_list('t.deb.foo')
self.archive_extract('t.deb.foo', check=None)
self.archive_test('t.deb.foo')
@needs_program('file')
@needs_program('lzop')
def test_lzop (self):
self.program = 'lzop'
self.archive_commands('t.lzo.foo', skip_create=True)
# file(1) does not recognize .lzma files
#@needs_program('file')
#@needs_program('lzma')
#def test_lzma (self):
# self.program = 'lzma'
# self.archive_test('t.lzma.foo')
# self.archive_extract('t.lzma.foo')
@needs_program('file')
@needs_program('lzip')
def test_lzip (self):
self.program = 'lzip'
self.archive_test('t.txt.lz.foo')
self.archive_extract('t.txt.lz.foo', check=Content.Singlefile)
@needs_program('file')
@needs_program('clzip')
def test_clzip (self):
self.program = 'clzip'
self.archive_test('t.txt.lz.foo')
self.archive_extract('t.txt.lz.foo', check=Content.Singlefile)
@needs_program('file')
@needs_program('plzip')
def test_plzip (self):
self.program = 'plzip'
self.archive_test('t.txt.lz.foo')
self.archive_extract('t.txt.lz.foo', check=Content.Singlefile)
@needs_program('file')
@needs_program('pdlzip')
def test_pdlzip (self):
self.program = 'pdlzip'
self.archive_test('t.txt.lz.foo')
self.archive_extract('t.txt.lz.foo', check=Content.Singlefile)
@needs_program('file')
@needs_program('xz')
def test_xz (self):
self.program = 'xz'
self.archive_test('t.txt.xz.foo')
self.archive_extract('t.txt.xz.foo', check=Content.Singlefile)
@needs_program('file')
@needs_program('lha')
def test_lha (self):
self.program = 'lha'
self.archive_commands('t.lha.foo', skip_create=True)
# file(1) does not recognize .alz files
#@needs_program('file')
#@needs_program('unalz')
#def test_unalz (self):
# self.program = 'unalz'
# self.archive_test('t.alz.foo')
# self.archive_list('t.alz.foo')
# self.archive_extract('t.alz.foo')
@needs_program('arc')
def test_arc (self):
self.program = 'arc'
self.archive_commands('t.arc.foo', skip_create=True)
@needs_program('nomarch')
def test_nomarch (self):
self.program = 'nomarch'
self.archive_test('t.arc.foo')
self.archive_list('t.arc.foo')
self.archive_extract('t.arc.foo')
# file(1) does not recognize .lrz files
#@needs_program('file')
#@needs_program('lrzip')
#def test_lrzip (self):
# self.program = 'lrzip'
# self.archive_test('t.txt.lrz.foo')
# self.archive_extract('t.txt.lrz.foo')
# self.archive_create('t.txt.lrz.foo', format="lrzip", singlefile=True)
@needs_program('rzip')
def test_rzip (self):
self.program = 'rzip'
self.archive_extract('t.txt.rz.foo')
# XXX test failure
#@needs_program('zoo')
#def test_zoo (self):
# self.program = 'zoo'
# self.archive_commands('t.zoo.foo', skip_create=True)
# xdms(1) cannot handle files without '.dms' extension
#@needs_program('xdms')
#def test_xdms (self):
# self.program = 'xdms'
# self.archive_extract('t.dms.foo')
# self.archive_test('t.dms.foo')
# self.archive_list('t.dms.foo')
@needs_program('unadf')
def test_unadf (self):
self.program = 'unadf'
self.archive_extract('t.adf.foo', check=None)
self.archive_test('t.adf.foo')
self.archive_list('t.adf.foo')
@needs_program('file')
@needs_program('mac')
def test_mac (self):
self.program = 'mac'
self.archive_extract('t.ape.foo', check=None)
# file(1) does not recognize .shn files
#@needs_program('file')
#@needs_program('shorten')
#def test_shorten (self):
# self.program = 'shorten'
# self.archive_extract('t.shn.foo', check=None)
@needs_program('file')
@needs_program('flac')
def test_flac (self):
self.program = 'flac'
self.archive_extract('t.flac.foo', check=None)
self.archive_test('t.flac.foo')