add test for --report argument and features.pilinfo(supported_formats)

This commit is contained in:
Nulano 2024-03-09 14:58:05 +01:00
parent 07f2b965ed
commit e5a46ef45d
2 changed files with 13 additions and 6 deletions

View File

@ -117,9 +117,10 @@ def test_unsupported_module() -> None:
features.version_module(module)
def test_pilinfo() -> None:
@pytest.mark.parametrize("supported_formats", (True, False))
def test_pilinfo(supported_formats) -> None:
buf = io.StringIO()
features.pilinfo(buf)
features.pilinfo(buf, supported_formats=supported_formats)
out = buf.getvalue()
lines = out.splitlines()
assert lines[0] == "-" * 68
@ -148,4 +149,4 @@ def test_pilinfo() -> None:
+ "-" * 68
+ "\n"
)
assert jpeg in out
assert supported_formats == (jpeg in out)

View File

@ -4,9 +4,15 @@ import os
import subprocess
import sys
import pytest
def test_main() -> None:
out = subprocess.check_output([sys.executable, "-m", "PIL"]).decode("utf-8")
@pytest.mark.parametrize("report", (False, True))
def test_main(report) -> None:
args = [sys.executable, "-m", "PIL"]
if report:
args.append("--report")
out = subprocess.check_output(args).decode("utf-8")
lines = out.splitlines()
assert lines[0] == "-" * 68
assert lines[1].startswith("Pillow ")
@ -37,4 +43,4 @@ def test_main() -> None:
+ "-" * 68
+ os.linesep
)
assert jpeg in out
assert report == (jpeg not in out)