mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-14 19:36:38 +03:00
Use monkeypatch
This commit is contained in:
parent
2a703a2d4c
commit
7554e2cfbf
|
@ -116,16 +116,14 @@ class TestImage:
|
||||||
assert im.mode == "RGB"
|
assert im.mode == "RGB"
|
||||||
assert im.size == (128, 128)
|
assert im.size == (128, 128)
|
||||||
|
|
||||||
def test_open_verbose_failure(self) -> None:
|
def test_open_verbose_failure(self, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||||
|
monkeypatch.setattr(Image, "WARN_POSSIBLE_FORMATS", True)
|
||||||
|
|
||||||
im = io.BytesIO(b"")
|
im = io.BytesIO(b"")
|
||||||
Image.WARN_POSSIBLE_FORMATS = True
|
with pytest.warns(UserWarning):
|
||||||
try:
|
with pytest.raises(UnidentifiedImageError):
|
||||||
with pytest.warns(UserWarning):
|
with Image.open(im):
|
||||||
with pytest.raises(UnidentifiedImageError):
|
pass
|
||||||
with Image.open(im):
|
|
||||||
pass
|
|
||||||
finally:
|
|
||||||
Image.WARN_POSSIBLE_FORMATS = False
|
|
||||||
|
|
||||||
def test_width_height(self) -> None:
|
def test_width_height(self) -> None:
|
||||||
im = Image.new("RGB", (1, 2))
|
im = Image.new("RGB", (1, 2))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user