Skip to content

Commit fa58313

Browse files
authored
Merge pull request #8759 from radarhere/tar
Improve TarIO test coverage
2 parents 1754125 + 19010bb commit fa58313

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Tests/test_file_tar.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import warnings
4+
from pathlib import Path
45

56
import pytest
67

@@ -29,6 +30,22 @@ def test_sanity(codec: str, test_path: str, format: str) -> None:
2930
assert im.format == format
3031

3132

33+
def test_unexpected_end(tmp_path: Path) -> None:
34+
tmpfile = str(tmp_path / "temp.tar")
35+
with open(tmpfile, "w"):
36+
pass
37+
38+
with pytest.raises(OSError, match="unexpected end of tar file"):
39+
with TarIO.TarIO(tmpfile, "test"):
40+
pass
41+
42+
43+
def test_cannot_find_subfile() -> None:
44+
with pytest.raises(OSError, match="cannot find subfile"):
45+
with TarIO.TarIO(TEST_TAR_FILE, "test"):
46+
pass
47+
48+
3249
@pytest.mark.skipif(is_pypy(), reason="Requires CPython")
3350
def test_unclosed_file() -> None:
3451
with pytest.warns(ResourceWarning):

0 commit comments

Comments
 (0)