-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from miurahr/patch-multiblock-timeout
Add new test and timeout
- Loading branch information
Showing
10 changed files
with
85 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ texttable | |
pytest | ||
pytest-benchmark[histogram] | ||
pytest-cov | ||
pytest-timeout | ||
coverage | ||
coveralls | ||
flake8 | ||
|
File renamed without changes.
File renamed without changes.
Binary file not shown.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os | ||
|
||
import py7zr | ||
import pytest | ||
from py7zr import UnsupportedCompressionMethodError | ||
|
||
from . import check_archive | ||
|
||
testdata_path = os.path.join(os.path.dirname(__file__), 'data') | ||
os.umask(0o022) | ||
|
||
|
||
@pytest.mark.files | ||
@pytest.mark.xfail(raises=UnsupportedCompressionMethodError) | ||
def test_copy(): | ||
""" test loading of copy compressed files.(help wanted)""" | ||
check_archive(py7zr.SevenZipFile(open(os.path.join(testdata_path, 'copy.7z'), 'rb'))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import binascii | ||
import hashlib | ||
import os | ||
import shutil | ||
import stat | ||
import tempfile | ||
|
||
import py7zr | ||
import pytest | ||
|
||
testdata_path = os.path.join(os.path.dirname(__file__), 'data') | ||
os.umask(0o022) | ||
|
||
|
||
def rmtree_onerror(func, path, exc_info): | ||
if not os.access(path, os.W_OK): | ||
os.chmod(path, stat.S_IWUSR) | ||
func(path) | ||
else: | ||
raise | ||
|
||
|
||
@pytest.mark.files | ||
def test_github_14_multi(): | ||
""" multiple unnamed objects.""" | ||
archive = py7zr.SevenZipFile(open(os.path.join(testdata_path, 'github_14_multi.7z'), 'rb')) | ||
assert archive.getnames() == ['github_14_multi', 'github_14_multi'] | ||
tmpdir = tempfile.mkdtemp() | ||
archive.extractall(path=tmpdir) | ||
with open(os.path.join(tmpdir, 'github_14_multi'), 'rb') as f: | ||
assert f.read() == bytes('Hello GitHub issue #14 2/2.\n', 'ascii') | ||
shutil.rmtree(tmpdir) | ||
|
||
|
||
@pytest.mark.files | ||
def test_multiblock(): | ||
archive = py7zr.SevenZipFile(open(os.path.join(testdata_path, 'mblock_1.7z'), 'rb')) | ||
tmpdir = tempfile.mkdtemp() | ||
archive.extractall(path=tmpdir) | ||
m = hashlib.sha256() | ||
m.update(open(os.path.join(tmpdir, 'bin/7zdec.exe'), 'rb').read()) | ||
assert m.digest() == binascii.unhexlify('e14d8201c5c0d1049e717a63898a3b1c7ce4054a24871daebaa717da64dcaff5') | ||
shutil.rmtree(tmpdir, onerror=rmtree_onerror) | ||
|
||
|
||
@pytest.mark.files | ||
def test_multiblock_zerosize(): | ||
archive = py7zr.SevenZipFile(open(os.path.join(testdata_path, 'mblock_2.7z'), 'rb')) | ||
tmpdir = tempfile.mkdtemp() | ||
archive.extractall(path=tmpdir) | ||
shutil.rmtree(tmpdir) | ||
|
||
|
||
@pytest.mark.files | ||
@pytest.mark.timeout(5, method='thread') | ||
@pytest.mark.xfail() | ||
def test_multiblock_last_padding(): | ||
archive = py7zr.SevenZipFile(open(os.path.join(testdata_path, 'mblock_3.7z'), 'rb')) | ||
tmpdir = tempfile.mkdtemp() | ||
archive.extractall(path=tmpdir) | ||
shutil.rmtree(tmpdir) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters