Skip to content

Commit 9762c9e

Browse files
committed
Test unexpected end of tar file
1 parent 8a3c4f5 commit 9762c9e

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

Tests/test_file_tar.py

Lines changed: 11 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,16 @@ 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):
39+
with TarIO.TarIO(tmpfile, "test"):
40+
pass
41+
42+
3243
@pytest.mark.skipif(is_pypy(), reason="Requires CPython")
3344
def test_unclosed_file() -> None:
3445
with pytest.warns(ResourceWarning):

0 commit comments

Comments
 (0)