mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-22 23:00:36 +03:00
Merge pull request #8759 from radarhere/tar
Improve TarIO test coverage
This commit is contained in:
commit
fa58313c41
|
@ -1,6 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import warnings
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
|
@ -29,6 +30,22 @@ def test_sanity(codec: str, test_path: str, format: str) -> None:
|
|||
assert im.format == format
|
||||
|
||||
|
||||
def test_unexpected_end(tmp_path: Path) -> None:
|
||||
tmpfile = str(tmp_path / "temp.tar")
|
||||
with open(tmpfile, "w"):
|
||||
pass
|
||||
|
||||
with pytest.raises(OSError, match="unexpected end of tar file"):
|
||||
with TarIO.TarIO(tmpfile, "test"):
|
||||
pass
|
||||
|
||||
|
||||
def test_cannot_find_subfile() -> None:
|
||||
with pytest.raises(OSError, match="cannot find subfile"):
|
||||
with TarIO.TarIO(TEST_TAR_FILE, "test"):
|
||||
pass
|
||||
|
||||
|
||||
@pytest.mark.skipif(is_pypy(), reason="Requires CPython")
|
||||
def test_unclosed_file() -> None:
|
||||
with pytest.warns(ResourceWarning):
|
||||
|
|
Loading…
Reference in New Issue
Block a user