File: test_util.py

package info (click to toggle)
pillow 12.0.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 72,636 kB
  • sloc: python: 49,518; ansic: 38,787; makefile: 302; sh: 168; javascript: 85
file content (41 lines) | stat: -rw-r--r-- 771 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from __future__ import annotations

from pathlib import Path, PurePath

import pytest

from PIL import _util


@pytest.mark.parametrize(
    "test_path", ["filename.ext", Path("filename.ext"), PurePath("filename.ext")]
)
def test_is_path(test_path: str | Path | PurePath) -> None:
    # Act
    it_is = _util.is_path(test_path)

    # Assert
    assert it_is


def test_is_not_path(tmp_path: Path) -> None:
    # Arrange
    with (tmp_path / "temp.ext").open("w") as fp:
        pass

    # Act
    it_is_not = _util.is_path(fp)

    # Assert
    assert not it_is_not


def test_deferred_error() -> None:
    # Arrange

    # Act
    thing = _util.DeferredError.new(ValueError("Some error text"))

    # Assert
    with pytest.raises(ValueError):
        thing.some_attr