From e5a46ef45dca79c024c5920a46909d8bba09a3ae Mon Sep 17 00:00:00 2001 From: Nulano Date: Sat, 9 Mar 2024 14:58:05 +0100 Subject: [PATCH] add test for --report argument and features.pilinfo(supported_formats) --- Tests/test_features.py | 7 ++++--- Tests/test_main.py | 12 +++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Tests/test_features.py b/Tests/test_features.py index 3fffa032f..3a528a7c8 100644 --- a/Tests/test_features.py +++ b/Tests/test_features.py @@ -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) diff --git a/Tests/test_main.py b/Tests/test_main.py index e13e0c5e3..9ed7fa3d6 100644 --- a/Tests/test_main.py +++ b/Tests/test_main.py @@ -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)