File: test_util.py

package info (click to toggle)
pillow 8.1.2%2Bdfsg-0.3%2Bdeb11u2
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 65,628 kB
  • sloc: python: 35,630; ansic: 31,009; makefile: 388; javascript: 114; sh: 77
file content (72 lines) | stat: -rw-r--r-- 1,044 bytes parent folder | download
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import pytest

from PIL import _util


def test_is_path():
    # Arrange
    fp = "filename.ext"

    # Act
    it_is = _util.isPath(fp)

    # Assert
    assert it_is


def test_path_obj_is_path():
    # Arrange
    from pathlib import Path

    test_path = Path("filename.ext")

    # Act
    it_is = _util.isPath(test_path)

    # Assert
    assert it_is


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

    # Act
    it_is_not = _util.isPath(fp)

    # Assert
    assert not it_is_not


def test_is_directory():
    # Arrange
    directory = "Tests"

    # Act
    it_is = _util.isDirectory(directory)

    # Assert
    assert it_is


def test_is_not_directory():
    # Arrange
    text = "abc"

    # Act
    it_is_not = _util.isDirectory(text)

    # Assert
    assert not it_is_not


def test_deferred_error():
    # Arrange

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

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