Skip to content

Commit

Permalink
Add test case reported at issue #359
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Miura <[email protected]>
  • Loading branch information
miurahr committed Sep 14, 2021
1 parent 2435ef7 commit 0c432f7
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
Binary file added tests/data/lzma2_nested.7z
Binary file not shown.
Binary file added tests/data/lzma2_ng.7z
Binary file not shown.
40 changes: 40 additions & 0 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,43 @@ def test_read_writed(tmp_path):
with py7zr.SevenZipFile(testdata_path.joinpath("mblock_1.7z").open(mode="rb")) as source:
target.writed(source.readall())
p7zip_test(tmp_path / "target.7z")


@pytest.mark.files
def test_nested_readall():
top_archive = testdata_path.joinpath("lzma2_nested.7z")
password = "avproof"
expected = {'Config.xml': 28360,
'0001000000000CFA_SAM_DATA': 65536,
'GetThis.csv': 885,
'SAM.log': 1832
}
def list_archive(archive):
for filename, content in archive.readall().items():
if (py7zr.is_7zfile(content)):
nested = py7zr.SevenZipFile(content, "r", password=password)
list_archive(nested)
else:
assert(expected[filename], len(content.read()))
archive.reset()

with py7zr.SevenZipFile(top_archive, "r", password=password) as arc:
list_archive(arc)


@pytest.mark.files
def test_readall_ng():
top_archive = testdata_path.joinpath("lzma2_ng.7z")
password = "avproof"
expected = {
'Config.xml', 28360,
'EventConsumer.log', 0,
'EventConsumer.txt', 1068,
'processes1.csv', 136588,
'processes1.log', 0,
'processes2.csv', 124443,
'processes2.log', 0,
}
with py7zr.SevenZipFile(top_archive, "r", password=password) as arc:
for filename, content in arc.readall().items():
assert (expected[filename], len(content.read()))

0 comments on commit 0c432f7

Please sign in to comment.