2023-12-21 14:13:31 +03:00
|
|
|
from __future__ import annotations
|
2024-01-20 14:23:03 +03:00
|
|
|
|
2019-05-25 21:11:33 +03:00
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
|
2024-03-09 16:58:05 +03:00
|
|
|
import pytest
|
2019-05-25 21:11:33 +03:00
|
|
|
|
2024-03-09 16:58:05 +03:00
|
|
|
|
2024-03-30 06:22:00 +03:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
"args, report",
|
2024-03-30 10:33:14 +03:00
|
|
|
((["PIL"], False), (["PIL", "--report"], True), (["PIL.report"], True)),
|
2024-03-30 06:22:00 +03:00
|
|
|
)
|
2024-06-09 08:16:17 +03:00
|
|
|
def test_main(args: list[str], report: bool) -> None:
|
2024-03-30 06:22:00 +03:00
|
|
|
args = [sys.executable, "-m"] + args
|
2024-03-09 16:58:05 +03:00
|
|
|
out = subprocess.check_output(args).decode("utf-8")
|
2019-11-04 01:18:55 +03:00
|
|
|
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
|
2024-02-20 22:37:33 +03:00
|
|
|
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
|
2019-11-04 01:18:55 +03:00
|
|
|
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
|
|
|
|
)
|
2024-03-09 16:58:05 +03:00
|
|
|
assert report == (jpeg not in out)
|