mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Use ipython PrettyPrinter, rather than custom class
This commit is contained in:
parent
d1d567bb59
commit
2ed8502d12
|
@ -51,7 +51,7 @@ build_script:
|
||||||
|
|
||||||
test_script:
|
test_script:
|
||||||
- cd c:\pillow
|
- cd c:\pillow
|
||||||
- '%PYTHON%\%EXECUTABLE% -m pip install pytest pytest-cov pytest-timeout defusedxml numpy olefile pyroma'
|
- '%PYTHON%\%EXECUTABLE% -m pip install pytest pytest-cov pytest-timeout defusedxml ipython numpy olefile pyroma'
|
||||||
- c:\"Program Files (x86)"\"Windows Kits"\10\Debuggers\x86\gflags.exe /p /enable %PYTHON%\%EXECUTABLE%
|
- c:\"Program Files (x86)"\"Windows Kits"\10\Debuggers\x86\gflags.exe /p /enable %PYTHON%\%EXECUTABLE%
|
||||||
- '%PYTHON%\%EXECUTABLE% -c "from PIL import Image"'
|
- '%PYTHON%\%EXECUTABLE% -c "from PIL import Image"'
|
||||||
- '%PYTHON%\%EXECUTABLE% -m pytest -vx --cov PIL --cov Tests --cov-report term --cov-report xml Tests'
|
- '%PYTHON%\%EXECUTABLE% -m pytest -vx --cov PIL --cov Tests --cov-report term --cov-report xml Tests'
|
||||||
|
|
|
@ -30,6 +30,7 @@ python3 -m pip install --upgrade pip
|
||||||
python3 -m pip install --upgrade wheel
|
python3 -m pip install --upgrade wheel
|
||||||
python3 -m pip install coverage
|
python3 -m pip install coverage
|
||||||
python3 -m pip install defusedxml
|
python3 -m pip install defusedxml
|
||||||
|
python3 -m pip install ipython
|
||||||
python3 -m pip install olefile
|
python3 -m pip install olefile
|
||||||
python3 -m pip install -U pytest
|
python3 -m pip install -U pytest
|
||||||
python3 -m pip install -U pytest-cov
|
python3 -m pip install -U pytest-cov
|
||||||
|
|
1
.github/workflows/macos-install.sh
vendored
1
.github/workflows/macos-install.sh
vendored
|
@ -23,6 +23,7 @@ export PKG_CONFIG_PATH="/usr/local/opt/openblas/lib/pkgconfig"
|
||||||
|
|
||||||
python3 -m pip install coverage
|
python3 -m pip install coverage
|
||||||
python3 -m pip install defusedxml
|
python3 -m pip install defusedxml
|
||||||
|
python3 -m pip install ipython
|
||||||
python3 -m pip install olefile
|
python3 -m pip install olefile
|
||||||
python3 -m pip install -U pytest
|
python3 -m pip install -U pytest
|
||||||
python3 -m pip install -U pytest-cov
|
python3 -m pip install -U pytest-cov
|
||||||
|
|
1
.github/workflows/test-cygwin.yml
vendored
1
.github/workflows/test-cygwin.yml
vendored
|
@ -74,6 +74,7 @@ jobs:
|
||||||
perl
|
perl
|
||||||
python3${{ matrix.python-minor-version }}-cython
|
python3${{ matrix.python-minor-version }}-cython
|
||||||
python3${{ matrix.python-minor-version }}-devel
|
python3${{ matrix.python-minor-version }}-devel
|
||||||
|
python3${{ matrix.python-minor-version }}-ipython
|
||||||
python3${{ matrix.python-minor-version }}-numpy
|
python3${{ matrix.python-minor-version }}-numpy
|
||||||
python3${{ matrix.python-minor-version }}-sip
|
python3${{ matrix.python-minor-version }}-sip
|
||||||
python3${{ matrix.python-minor-version }}-tkinter
|
python3${{ matrix.python-minor-version }}-tkinter
|
||||||
|
|
|
@ -42,6 +42,12 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
ElementTree = None
|
ElementTree = None
|
||||||
|
|
||||||
|
PrettyPrinter: type | None
|
||||||
|
try:
|
||||||
|
from IPython.lib.pretty import PrettyPrinter
|
||||||
|
except ImportError:
|
||||||
|
PrettyPrinter = None
|
||||||
|
|
||||||
|
|
||||||
# Deprecation helper
|
# Deprecation helper
|
||||||
def helper_image_new(mode: str, size: tuple[int, int]) -> Image.Image:
|
def helper_image_new(mode: str, size: tuple[int, int]) -> Image.Image:
|
||||||
|
@ -91,16 +97,15 @@ class TestImage:
|
||||||
# with pytest.raises(MemoryError):
|
# with pytest.raises(MemoryError):
|
||||||
# Image.new("L", (1000000, 1000000))
|
# Image.new("L", (1000000, 1000000))
|
||||||
|
|
||||||
|
@pytest.mark.skipif(PrettyPrinter is None, reason="IPython is not installed")
|
||||||
def test_repr_pretty(self) -> None:
|
def test_repr_pretty(self) -> None:
|
||||||
class Pretty:
|
|
||||||
def text(self, text: str) -> None:
|
|
||||||
self.pretty_output = text
|
|
||||||
|
|
||||||
im = Image.new("L", (100, 100))
|
im = Image.new("L", (100, 100))
|
||||||
|
|
||||||
p = Pretty()
|
output = io.StringIO()
|
||||||
|
assert PrettyPrinter is not None
|
||||||
|
p = PrettyPrinter(output)
|
||||||
im._repr_pretty_(p, False)
|
im._repr_pretty_(p, False)
|
||||||
assert p.pretty_output == "<PIL.Image.Image image mode=L size=100x100>"
|
assert output.getvalue() == "<PIL.Image.Image image mode=L size=100x100>"
|
||||||
|
|
||||||
def test_open_formats(self) -> None:
|
def test_open_formats(self) -> None:
|
||||||
PNGFILE = "Tests/images/hopper.png"
|
PNGFILE = "Tests/images/hopper.png"
|
||||||
|
|
|
@ -221,6 +221,8 @@ if TYPE_CHECKING:
|
||||||
import mmap
|
import mmap
|
||||||
from xml.etree.ElementTree import Element
|
from xml.etree.ElementTree import Element
|
||||||
|
|
||||||
|
from IPython.lib.pretty import PrettyPrinter
|
||||||
|
|
||||||
from . import ImageFile, ImageFilter, ImagePalette, TiffImagePlugin
|
from . import ImageFile, ImageFilter, ImagePalette, TiffImagePlugin
|
||||||
from ._typing import NumpyArray, StrOrBytesPath, TypeGuard
|
from ._typing import NumpyArray, StrOrBytesPath, TypeGuard
|
||||||
ID: list[str] = []
|
ID: list[str] = []
|
||||||
|
@ -677,7 +679,7 @@ class Image:
|
||||||
id(self),
|
id(self),
|
||||||
)
|
)
|
||||||
|
|
||||||
def _repr_pretty_(self, p, cycle: bool) -> None:
|
def _repr_pretty_(self, p: PrettyPrinter, cycle: bool) -> None:
|
||||||
"""IPython plain text display support"""
|
"""IPython plain text display support"""
|
||||||
|
|
||||||
# Same as __repr__ but without unpredictable id(self),
|
# Same as __repr__ but without unpredictable id(self),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user