Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7c466f9

Browse files
QuLogictimhoffm
andcommitted
Document the text_placeholders fixture
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
1 parent3e8e9f8 commit7c466f9

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

‎doc/devel/testing.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,10 @@ the tests, they should now pass.
163163

164164
It is preferred that new tests use ``style='mpl20'`` as this leads to smaller
165165
figures and reflects the newer look of default Matplotlib plots. Also, if the
166-
texts (labels, tick labels, etc) are not really part of what is tested, use
167-
``remove_text=True`` as this will lead to smaller figures and reduce possible
168-
issues with font mismatch on different platforms.
166+
texts (labels, tick labels, etc) are not really part of what is tested, use the
167+
``remove_text=True`` argument or add the ``text_placeholders`` fixture as this
168+
will lead to smaller figures and reduce possible issues with font mismatch on
169+
different platforms.
169170

170171

171172
Compare two methods of creating an image

‎lib/matplotlib/testing/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ def test_imshow_xarray(xr):
129129

130130
@pytest.fixture
131131
deftext_placeholders(monkeypatch):
132+
"""
133+
Replace texts with placeholder rectangles.
134+
135+
The rectangle size only depends on the font size and the number of characters. It is
136+
thus insensitive to font properties and rendering details. This should be used for
137+
tests that depend on text geometries but not the actual text rendering, e.g. layout
138+
tests.
139+
"""
132140
frommatplotlib.patchesimportRectangle
133141

134142
defpatched_get_text_metrics_with_cache(renderer,text,fontprop,ismath,dpi):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp