mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 01:16:16 +03:00
Merge pull request #7818 from nulano/bugreport
This commit is contained in:
commit
a4e5dc219c
15
.github/ISSUE_TEMPLATE/ISSUE_REPORT.md
vendored
15
.github/ISSUE_TEMPLATE/ISSUE_REPORT.md
vendored
|
@ -48,6 +48,21 @@ Thank you.
|
||||||
* Python:
|
* Python:
|
||||||
* Pillow:
|
* Pillow:
|
||||||
|
|
||||||
|
```text
|
||||||
|
Please paste here the output of running:
|
||||||
|
|
||||||
|
python3 -m PIL.report
|
||||||
|
or
|
||||||
|
python3 -m PIL --report
|
||||||
|
|
||||||
|
Or the output of the following Python code:
|
||||||
|
|
||||||
|
from PIL import report
|
||||||
|
# or
|
||||||
|
from PIL import features
|
||||||
|
features.pilinfo(supported_formats=False)
|
||||||
|
```
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Please include **code** that reproduces the issue and whenever possible, an **image** that demonstrates the issue. Please upload images to GitHub, not to third-party file hosting sites. If necessary, add the image to a zip or tar archive.
|
Please include **code** that reproduces the issue and whenever possible, an **image** that demonstrates the issue. Please upload images to GitHub, not to third-party file hosting sites. If necessary, add the image to a zip or tar archive.
|
||||||
|
|
||||||
|
|
|
@ -117,9 +117,10 @@ def test_unsupported_module() -> None:
|
||||||
features.version_module(module)
|
features.version_module(module)
|
||||||
|
|
||||||
|
|
||||||
def test_pilinfo() -> None:
|
@pytest.mark.parametrize("supported_formats", (True, False))
|
||||||
|
def test_pilinfo(supported_formats) -> None:
|
||||||
buf = io.StringIO()
|
buf = io.StringIO()
|
||||||
features.pilinfo(buf)
|
features.pilinfo(buf, supported_formats=supported_formats)
|
||||||
out = buf.getvalue()
|
out = buf.getvalue()
|
||||||
lines = out.splitlines()
|
lines = out.splitlines()
|
||||||
assert lines[0] == "-" * 68
|
assert lines[0] == "-" * 68
|
||||||
|
@ -129,9 +130,15 @@ def test_pilinfo() -> None:
|
||||||
while lines[0].startswith(" "):
|
while lines[0].startswith(" "):
|
||||||
lines = lines[1:]
|
lines = lines[1:]
|
||||||
assert lines[0] == "-" * 68
|
assert lines[0] == "-" * 68
|
||||||
assert lines[1].startswith("Python modules loaded from ")
|
assert lines[1].startswith("Python executable is")
|
||||||
assert lines[2].startswith("Binary modules loaded from ")
|
lines = lines[2:]
|
||||||
assert lines[3] == "-" * 68
|
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 = (
|
jpeg = (
|
||||||
"\n"
|
"\n"
|
||||||
+ "-" * 68
|
+ "-" * 68
|
||||||
|
@ -142,4 +149,4 @@ def test_pilinfo() -> None:
|
||||||
+ "-" * 68
|
+ "-" * 68
|
||||||
+ "\n"
|
+ "\n"
|
||||||
)
|
)
|
||||||
assert jpeg in out
|
assert supported_formats == (jpeg in out)
|
||||||
|
|
|
@ -4,9 +4,16 @@ import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
def test_main() -> None:
|
|
||||||
out = subprocess.check_output([sys.executable, "-m", "PIL"]).decode("utf-8")
|
@pytest.mark.parametrize(
|
||||||
|
"args, report",
|
||||||
|
((["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()
|
lines = out.splitlines()
|
||||||
assert lines[0] == "-" * 68
|
assert lines[0] == "-" * 68
|
||||||
assert lines[1].startswith("Pillow ")
|
assert lines[1].startswith("Pillow ")
|
||||||
|
@ -15,9 +22,15 @@ def test_main() -> None:
|
||||||
while lines[0].startswith(" "):
|
while lines[0].startswith(" "):
|
||||||
lines = lines[1:]
|
lines = lines[1:]
|
||||||
assert lines[0] == "-" * 68
|
assert lines[0] == "-" * 68
|
||||||
assert lines[1].startswith("Python modules loaded from ")
|
assert lines[1].startswith("Python executable is")
|
||||||
assert lines[2].startswith("Binary modules loaded from ")
|
lines = lines[2:]
|
||||||
assert lines[3] == "-" * 68
|
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 = (
|
jpeg = (
|
||||||
os.linesep
|
os.linesep
|
||||||
+ "-" * 68
|
+ "-" * 68
|
||||||
|
@ -31,4 +44,4 @@ def test_main() -> None:
|
||||||
+ "-" * 68
|
+ "-" * 68
|
||||||
+ os.linesep
|
+ os.linesep
|
||||||
)
|
)
|
||||||
assert jpeg in out
|
assert report == (jpeg not in out)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
from .features import pilinfo
|
from .features import pilinfo
|
||||||
|
|
||||||
pilinfo()
|
pilinfo(supported_formats="--report" not in sys.argv)
|
||||||
|
|
|
@ -230,6 +230,9 @@ def pilinfo(out=None, supported_formats=True):
|
||||||
"""
|
"""
|
||||||
Prints information about this installation of Pillow.
|
Prints information about this installation of Pillow.
|
||||||
This function can be called with ``python3 -m PIL``.
|
This function can be called with ``python3 -m PIL``.
|
||||||
|
It can also be called with ``python3 -m PIL.report`` or ``python3 -m PIL --report``
|
||||||
|
to have "supported_formats" set to ``False``, omitting the list of all supported
|
||||||
|
image file formats.
|
||||||
|
|
||||||
:param out:
|
:param out:
|
||||||
The output stream to print to. Defaults to ``sys.stdout`` if ``None``.
|
The output stream to print to. Defaults to ``sys.stdout`` if ``None``.
|
||||||
|
@ -249,12 +252,17 @@ def pilinfo(out=None, supported_formats=True):
|
||||||
for py_version in py_version[1:]:
|
for py_version in py_version[1:]:
|
||||||
print(f" {py_version.strip()}", file=out)
|
print(f" {py_version.strip()}", file=out)
|
||||||
print("-" * 68, file=out)
|
print("-" * 68, file=out)
|
||||||
|
print(f"Python executable is {sys.executable or 'unknown'}", file=out)
|
||||||
|
if sys.prefix != sys.base_prefix:
|
||||||
|
print(f"Environment Python files loaded from {sys.prefix}", file=out)
|
||||||
|
print(f"System Python files loaded from {sys.base_prefix}", file=out)
|
||||||
|
print("-" * 68, file=out)
|
||||||
print(
|
print(
|
||||||
f"Python modules loaded from {os.path.dirname(Image.__file__)}",
|
f"Python Pillow modules loaded from {os.path.dirname(Image.__file__)}",
|
||||||
file=out,
|
file=out,
|
||||||
)
|
)
|
||||||
print(
|
print(
|
||||||
f"Binary modules loaded from {os.path.dirname(Image.core.__file__)}",
|
f"Binary Pillow modules loaded from {os.path.dirname(Image.core.__file__)}",
|
||||||
file=out,
|
file=out,
|
||||||
)
|
)
|
||||||
print("-" * 68, file=out)
|
print("-" * 68, file=out)
|
||||||
|
|
5
src/PIL/report.py
Normal file
5
src/PIL/report.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from .features import pilinfo
|
||||||
|
|
||||||
|
pilinfo(supported_formats=False)
|
Loading…
Reference in New Issue
Block a user