Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Tests/test_file_tar.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import warnings
from pathlib import Path

import pytest

Expand Down Expand Up @@ -29,6 +30,22 @@
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

Check warning on line 40 in Tests/test_file_tar.py

View check run for this annotation

Codecov / codecov/patch

Tests/test_file_tar.py#L40

Added line #L40 was not covered by tests


def test_cannot_find_subfile() -> None:
with pytest.raises(OSError, match="cannot find subfile"):
with TarIO.TarIO(TEST_TAR_FILE, "test"):
pass

Check warning on line 46 in Tests/test_file_tar.py

View check run for this annotation

Codecov / codecov/patch

Tests/test_file_tar.py#L46

Added line #L46 was not covered by tests


@pytest.mark.skipif(is_pypy(), reason="Requires CPython")
def test_unclosed_file() -> None:
with pytest.warns(ResourceWarning):
Expand Down
Loading