Pillow
1from __future__ import annotations
2
3from pathlib import Path, PurePath
4
5import pytest
6
7from PIL import _util
8
9
10@pytest.mark.parametrize(
11"test_path", ["filename.ext", Path("filename.ext"), PurePath("filename.ext")]
12)
13def test_is_path(test_path: str | Path | PurePath) -> None:
14# Act
15it_is = _util.is_path(test_path)
16
17# Assert
18assert it_is
19
20
21def test_is_not_path(tmp_path: Path) -> None:
22# Arrange
23with (tmp_path / "temp.ext").open("w") as fp:
24pass
25
26# Act
27it_is_not = _util.is_path(fp)
28
29# Assert
30assert not it_is_not
31
32
33def test_deferred_error() -> None:
34# Arrange
35
36# Act
37thing = _util.DeferredError.new(ValueError("Some error text"))
38
39# Assert
40with pytest.raises(ValueError):
41thing.some_attr
42