Pillow/Tests/test_main.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

48 lines
1.4 KiB
Python
Raw Normal View History

from __future__ import annotations
2024-01-20 14:23:03 +03:00
Add __main__.py to output basic format and support information To help debug and show supported formats, users can run: $ python -m PIL to get basic format and support information about the installed version of Pillow. The new feature works as follows: $ python -m PIL -------------------------------------------------------------------- Pillow 6.1.0.dev0 -------------------------------------------------------------------- Python modules loaded from .../Pillow/src/PIL Binary modules loaded from .../Pillow/src/PIL -------------------------------------------------------------------- Python 3.7.3 (default, May 11 2019, 00:38:04) [GCC 9.1.1 20190503 (Red Hat 9.1.1-1)] -------------------------------------------------------------------- --- PIL CORE support ok --- TKINTER support ok --- FREETYPE2 support ok --- LITTLECMS2 support ok --- WEBP support ok --- WEBP Transparency support ok --- WEBPMUX support ok --- WEBP Animation support ok --- JPEG support ok --- OPENJPEG (JPEG2000) support ok --- ZLIB (PNG/ZIP) support ok --- LIBTIFF support ok --- RAQM (Bidirectional Text) support ok -------------------------------------------------------------------- BLP Extensions: .blp Features: open -------------------------------------------------------------------- BMP image/bmp Extensions: .bmp Features: open, save -------------------------------------------------------------------- BUFR Extensions: .bufr Features: open, save -------------------------------------------------------------------- …
2019-05-25 21:11:33 +03:00
import os
import subprocess
import sys
import pytest
Add __main__.py to output basic format and support information To help debug and show supported formats, users can run: $ python -m PIL to get basic format and support information about the installed version of Pillow. The new feature works as follows: $ python -m PIL -------------------------------------------------------------------- Pillow 6.1.0.dev0 -------------------------------------------------------------------- Python modules loaded from .../Pillow/src/PIL Binary modules loaded from .../Pillow/src/PIL -------------------------------------------------------------------- Python 3.7.3 (default, May 11 2019, 00:38:04) [GCC 9.1.1 20190503 (Red Hat 9.1.1-1)] -------------------------------------------------------------------- --- PIL CORE support ok --- TKINTER support ok --- FREETYPE2 support ok --- LITTLECMS2 support ok --- WEBP support ok --- WEBP Transparency support ok --- WEBPMUX support ok --- WEBP Animation support ok --- JPEG support ok --- OPENJPEG (JPEG2000) support ok --- ZLIB (PNG/ZIP) support ok --- LIBTIFF support ok --- RAQM (Bidirectional Text) support ok -------------------------------------------------------------------- BLP Extensions: .blp Features: open -------------------------------------------------------------------- BMP image/bmp Extensions: .bmp Features: open, save -------------------------------------------------------------------- BUFR Extensions: .bufr Features: open, save -------------------------------------------------------------------- …
2019-05-25 21:11:33 +03:00
@pytest.mark.parametrize(
"args, report",
2024-03-30 10:33:14 +03:00
((["PIL"], False), (["PIL", "--report"], True), (["PIL.report"], True)),
)
def test_main(args, report) -> None:
args = [sys.executable, "-m"] + args
out = subprocess.check_output(args).decode("utf-8")
lines = out.splitlines()
assert lines[0] == "-" * 68
assert lines[1].startswith("Pillow ")
assert lines[2].startswith("Python ")
lines = lines[3:]
while lines[0].startswith(" "):
lines = lines[1:]
assert lines[0] == "-" * 68
assert lines[1].startswith("Python executable is")
lines = lines[2:]
if lines[0].startswith("Environment Python files loaded from"):
lines = lines[1:]
assert lines[0].startswith("System Python files loaded from")
assert lines[1] == "-" * 68
assert lines[2].startswith("Python Pillow modules loaded from ")
assert lines[3].startswith("Binary Pillow modules loaded from ")
assert lines[4] == "-" * 68
jpeg = (
os.linesep
+ "-" * 68
+ os.linesep
+ "JPEG image/jpeg"
+ os.linesep
+ "Extensions: .jfif, .jpe, .jpeg, .jpg"
+ os.linesep
+ "Features: open, save"
+ os.linesep
+ "-" * 68
+ os.linesep
)
assert report == (jpeg not in out)