Pillow

Форк
0
/
test_file_gimppalette.py 
34 строки · 866.0 Байт
1
from __future__ import annotations
2

3
import pytest
4

5
from PIL.GimpPaletteFile import GimpPaletteFile
6

7

8
def test_sanity() -> None:
9
    with open("Tests/images/test.gpl", "rb") as fp:
10
        GimpPaletteFile(fp)
11

12
    with open("Tests/images/hopper.jpg", "rb") as fp:
13
        with pytest.raises(SyntaxError):
14
            GimpPaletteFile(fp)
15

16
    with open("Tests/images/bad_palette_file.gpl", "rb") as fp:
17
        with pytest.raises(SyntaxError):
18
            GimpPaletteFile(fp)
19

20
    with open("Tests/images/bad_palette_entry.gpl", "rb") as fp:
21
        with pytest.raises(ValueError):
22
            GimpPaletteFile(fp)
23

24

25
def test_get_palette() -> None:
26
    # Arrange
27
    with open("Tests/images/custom_gimp_palette.gpl", "rb") as fp:
28
        palette_file = GimpPaletteFile(fp)
29

30
    # Act
31
    palette, mode = palette_file.getpalette()
32

33
    # Assert
34
    assert mode == "RGB"
35

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.