From e471b3f27f13581ef07ec938d042bff1c182e91d Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Thu, 20 Apr 2023 19:58:26 +0200 Subject: [PATCH] Add tests for missing text wrap cases --- lib/matplotlib/tests/test_text.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tests/test_text.py b/lib/matplotlib/tests/test_text.py index a3d3a8e29678..4bccea238395 100644 --- a/lib/matplotlib/tests/test_text.py +++ b/lib/matplotlib/tests/test_text.py @@ -690,10 +690,16 @@ def test_large_subscript_title(): ax.set_xticklabels([]) -def test_wrap(): - fig = plt.figure(figsize=(6, 4)) +@pytest.mark.parametrize( + "x, rotation, halign", + [(0.7, 0, 'left'), + (0.5, 95, 'left'), + (0.3, 0, 'right'), + (0.3, 185, 'left')]) +def test_wrap(x, rotation, halign): + fig = plt.figure(figsize=(6, 6)) s = 'This is a very long text that should be wrapped multiple times.' - text = fig.text(0.7, 0.5, s, wrap=True) + text = fig.text(x, 0.7, s, wrap=True, rotation=rotation, ha=halign) fig.canvas.draw() assert text._get_wrapped_text() == ('This is a very long\n' 'text that should be\n'