patool/tests/archives/test_7z.py

163 lines
6.1 KiB
Python
Raw Normal View History

2012-11-14 19:24:34 +00:00
# -*- coding: utf-8 -*-
2016-01-09 20:09:27 +00:00
# Copyright (C) 2010-2016 Bastian Kleineidam
2012-11-14 19:24:34 +00:00
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
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')
2016-01-09 19:58:15 +00:00
self.archive_commands('t .cb7')
2012-11-14 19:24:34 +00:00
self.archive_commands('t.zip')
2016-01-09 19:58:15 +00:00
self.archive_commands('t.cbz')
2013-02-27 19:05:54 +00:00
self.archive_commands('t.txt.xz', check=Content.Singlefile)
2012-11-14 19:24:34 +00:00
self.archive_list('t.txt.gz')
self.archive_list('t.txt.bz2')
2013-02-27 19:20:02 +00:00
self.archive_list('t.txt.lzma')
2012-11-14 19:24:34 +00:00
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')
2013-02-27 18:38:07 +00:00
self.archive_list('t.iso')
2015-12-10 19:14:53 +00:00
self.archive_list('t.vhd')
2012-11-14 19:24:34 +00:00
self.archive_extract('t.txt.gz', check=Content.Singlefile)
self.archive_extract('t.txt.bz2', check=Content.Singlefile)
2013-02-27 19:20:02 +00:00
self.archive_extract('t.txt.lzma', check=Content.Singlefile)
2012-11-14 19:24:34 +00:00
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)
2013-02-27 18:38:07 +00:00
self.archive_extract('t.iso')
2015-12-10 19:14:53 +00:00
self.archive_extract('t.vhd', check=None)
2012-11-14 19:24:34 +00:00
self.archive_test('t.txt.gz')
self.archive_test('t.txt.bz2')
2013-02-27 19:20:02 +00:00
self.archive_test('t.txt.lzma')
2012-11-14 19:24:34 +00:00
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')
2013-02-27 18:38:07 +00:00
self.archive_test('t.iso')
2015-12-10 19:14:53 +00:00
self.archive_test('t.vhd')
self.archive_create('t.txt.gz', check=Content.Singlefile)
2015-07-19 15:29:33 +00:00
self.archive_create('t.txt.bz2', check=Content.Singlefile)
2012-11-14 19:24:34 +00:00
@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)
2016-01-09 19:58:15 +00:00
self.archive_commands('t.cb7.foo', skip_create=True)
2012-11-14 19:24:34 +00:00
self.archive_commands('t.zip.foo', skip_create=True)
2016-01-09 19:58:15 +00:00
self.archive_commands('t.cbz.foo', skip_create=True)
2013-02-27 19:05:54 +00:00
self.archive_commands('t.txt.xz.foo', skip_create=True, check=Content.Singlefile)
2012-11-14 19:24:34 +00:00
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')
2013-02-27 18:38:07 +00:00
self.archive_list('t.iso.foo')
2012-11-14 19:24:34 +00:00
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)
2013-02-27 18:38:07 +00:00
self.archive_extract('t.iso.foo')
2012-11-14 19:24:34 +00:00
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')
2013-02-27 18:38:07 +00:00
self.archive_test('t.iso.foo')
2012-11-14 19:24:34 +00:00
@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(self.filename + '.rar.foo')
self.archive_extract(self.filename + '.rar.foo')
self.archive_test(self.filename + '.rar.foo')
class Test7zPassword(ArchiveTest):
program = '7z'
password = 'thereisnotry'
@needs_program(program)
def test_7z (self):
self.archive_commands('p .7z')
self.archive_commands('p.zip')
self.archive_commands('p.cbz')
self.archive_list('p.arj')
self.archive_extract('p.arj')
self.archive_test('p.arj')
@needs_codec(program, 'rar')
def test_7z_rar (self):
# only succeeds with the rar module for 7z installed
self.archive_list('p.rar')
self.archive_extract('p.rar')
self.archive_test('p.rar')
@needs_program('file')
@needs_program(program)
def test_7z_file (self):
self.archive_commands('p.7z.foo', skip_create=True)
self.archive_commands('p.zip.foo', skip_create=True)
self.archive_commands('p.cbz.foo', skip_create=True)
self.archive_list('p.arj.foo')
self.archive_extract('p.arj.foo')
self.archive_test('p.arj.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('p.rar.foo')
self.archive_extract('p.rar.foo')
self.archive_test('p.rar.foo')