mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Fix up pytest.raises lambda: uses
This commit is contained in:
parent
583dd3b424
commit
5c8a9165ab
|
@ -351,7 +351,8 @@ def test_rotated_transposed_font(font, orientation):
|
|||
assert bbox_b[3] == 20 + bbox_a[2] - bbox_a[0]
|
||||
|
||||
# text length is undefined for vertical text
|
||||
pytest.raises(ValueError, draw.textlength, word)
|
||||
with pytest.raises(ValueError):
|
||||
draw.textlength(word)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
@ -872,25 +873,23 @@ def test_anchor_invalid(font):
|
|||
d.font = font
|
||||
|
||||
for anchor in ["", "l", "a", "lax", "sa", "xa", "lx"]:
|
||||
pytest.raises(ValueError, lambda: font.getmask2("hello", anchor=anchor))
|
||||
pytest.raises(ValueError, lambda: font.getbbox("hello", anchor=anchor))
|
||||
pytest.raises(ValueError, lambda: d.text((0, 0), "hello", anchor=anchor))
|
||||
pytest.raises(ValueError, lambda: d.textbbox((0, 0), "hello", anchor=anchor))
|
||||
pytest.raises(
|
||||
ValueError, lambda: d.multiline_text((0, 0), "foo\nbar", anchor=anchor)
|
||||
)
|
||||
pytest.raises(
|
||||
ValueError,
|
||||
lambda: d.multiline_textbbox((0, 0), "foo\nbar", anchor=anchor),
|
||||
)
|
||||
with pytest.raises(ValueError):
|
||||
font.getmask2("hello", anchor=anchor)
|
||||
with pytest.raises(ValueError):
|
||||
font.getbbox("hello", anchor=anchor)
|
||||
with pytest.raises(ValueError):
|
||||
d.text((0, 0), "hello", anchor=anchor)
|
||||
with pytest.raises(ValueError):
|
||||
d.textbbox((0, 0), "hello", anchor=anchor)
|
||||
with pytest.raises(ValueError):
|
||||
d.multiline_text((0, 0), "foo\nbar", anchor=anchor)
|
||||
with pytest.raises(ValueError):
|
||||
d.multiline_textbbox((0, 0), "foo\nbar", anchor=anchor)
|
||||
for anchor in ["lt", "lb"]:
|
||||
pytest.raises(
|
||||
ValueError, lambda: d.multiline_text((0, 0), "foo\nbar", anchor=anchor)
|
||||
)
|
||||
pytest.raises(
|
||||
ValueError,
|
||||
lambda: d.multiline_textbbox((0, 0), "foo\nbar", anchor=anchor),
|
||||
)
|
||||
with pytest.raises(ValueError):
|
||||
d.multiline_text((0, 0), "foo\nbar", anchor=anchor)
|
||||
with pytest.raises(ValueError):
|
||||
d.multiline_textbbox((0, 0), "foo\nbar", anchor=anchor)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("bpp", (1, 2, 4, 8))
|
||||
|
|
|
@ -360,37 +360,20 @@ def test_anchor_invalid_ttb():
|
|||
d.font = font
|
||||
|
||||
for anchor in ["", "l", "a", "lax", "xa", "la", "ls", "ld", "lx"]:
|
||||
pytest.raises(
|
||||
ValueError, lambda: font.getmask2("hello", anchor=anchor, direction="ttb")
|
||||
)
|
||||
pytest.raises(
|
||||
ValueError, lambda: font.getbbox("hello", anchor=anchor, direction="ttb")
|
||||
)
|
||||
pytest.raises(
|
||||
ValueError, lambda: d.text((0, 0), "hello", anchor=anchor, direction="ttb")
|
||||
)
|
||||
pytest.raises(
|
||||
ValueError,
|
||||
lambda: d.textbbox((0, 0), "hello", anchor=anchor, direction="ttb"),
|
||||
)
|
||||
pytest.raises(
|
||||
ValueError,
|
||||
lambda: d.multiline_text(
|
||||
(0, 0), "foo\nbar", anchor=anchor, direction="ttb"
|
||||
),
|
||||
)
|
||||
pytest.raises(
|
||||
ValueError,
|
||||
lambda: d.multiline_textbbox(
|
||||
(0, 0), "foo\nbar", anchor=anchor, direction="ttb"
|
||||
),
|
||||
)
|
||||
with pytest.raises(ValueError):
|
||||
font.getmask2("hello", anchor=anchor, direction="ttb")
|
||||
with pytest.raises(ValueError):
|
||||
font.getbbox("hello", anchor=anchor, direction="ttb")
|
||||
with pytest.raises(ValueError):
|
||||
d.text((0, 0), "hello", anchor=anchor, direction="ttb")
|
||||
with pytest.raises(ValueError):
|
||||
d.textbbox((0, 0), "hello", anchor=anchor, direction="ttb")
|
||||
with pytest.raises(ValueError):
|
||||
d.multiline_text((0, 0), "foo\nbar", anchor=anchor, direction="ttb")
|
||||
with pytest.raises(ValueError):
|
||||
d.multiline_textbbox((0, 0), "foo\nbar", anchor=anchor, direction="ttb")
|
||||
# ttb multiline text does not support anchors at all
|
||||
pytest.raises(
|
||||
ValueError,
|
||||
lambda: d.multiline_text((0, 0), "foo\nbar", anchor="mm", direction="ttb"),
|
||||
)
|
||||
pytest.raises(
|
||||
ValueError,
|
||||
lambda: d.multiline_textbbox((0, 0), "foo\nbar", anchor="mm", direction="ttb"),
|
||||
)
|
||||
with pytest.raises(ValueError):
|
||||
d.multiline_text((0, 0), "foo\nbar", anchor="mm", direction="ttb")
|
||||
with pytest.raises(ValueError):
|
||||
d.multiline_textbbox((0, 0), "foo\nbar", anchor="mm", direction="ttb")
|
||||
|
|
Loading…
Reference in New Issue
Block a user