Skip to content
This repository has been archived by the owner on Jul 16, 2022. It is now read-only.

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
  • Loading branch information
miurahr committed Feb 23, 2021
1 parent 8710d60 commit 8e5bce7
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/test_multivolume.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,30 @@ def test_write(tmp_path):
assert created.stat().st_size == 10240


def test_write_posixpath(tmp_path):
target = tmp_path.joinpath('target.7z').as_posix()
with MV.open(target, mode='wb', volume=10240) as volume:
assert volume.writable()
with open(os.path.join(testdata_path, "archive.7z.001"), 'rb') as r:
data = r.read(BLOCKSIZE)
while len(data) > 0:
volume.write(data)
data = r.read(BLOCKSIZE)

with open(os.path.join(testdata_path, "archive.7z.002"), 'rb') as r:
data = r.read(BLOCKSIZE)
while len(data) > 0:
volume.write(data)
data = r.read(BLOCKSIZE)
assert volume.seekable()
volume.seek(0)
volume.seek(51000)
volume.flush()
created = tmp_path.joinpath('target.7z.0001')
assert created.exists()
assert created.stat().st_size == 10240


def test_write_boundary(tmp_path):
target = tmp_path.joinpath('target.7z')
with MV.open(target, mode='wb', volume=10240) as volume:
Expand Down Expand Up @@ -251,3 +275,10 @@ def test_write_hex_digits(tmp_path):
created = tmp_path.joinpath('target.7z.00c')
assert created.exists()
assert created.stat().st_size == 650


def test_unsupported_open_mode(tmp_path):
target = tmp_path.joinpath('target.7z')
with pytest.raises(NotImplementedError):
with MV.MultiVolume(target, mode='qb', volume=800):
pass

0 comments on commit 8e5bce7

Please sign in to comment.