@@ -103,22 +103,22 @@ to the folder where the baseline test images are stored. The triage tool require
103103Writing tests
104104-------------
105105Tests are located in :file: `lib/matplotlib/tests `. They are organized to mirror
106- the structure of the main code in :file: `lib/matplotlib `. For example, tests for
106+ the structure of the code in :file: `lib/matplotlib `. For example, tests for
107107the ``mathtext.py `` module are in :file: `lib/matplotlib/tests/test_mathtext.py `.
108108
109109Naming follows standard pytest conventions:
110110
111111- files begin with ``"test_" ``
112112- test functions begin with ``"test_" ``
113- - test class begin ``"Test" ``.
113+ - test classes begin with ``"Test" ``.
114114
115115We prefer simple test functions, but test classes are also acceptable.
116116Test function names should be descriptive of what they are testing, and long names
117117like ``test_to_rgba_array_accepts_color_alpha_tuple_with_multiple_colors() `` are
118118perfectly fine.
119119
120- Simple unit tests
121- ^^^^^^^^^^^^^^^^^
120+ Unit tests
121+ ^^^^^^^^^^
122122
123123Many elements of Matplotlib can be tested using simple unit tests, e.g. ::
124124
@@ -127,17 +127,17 @@ Many elements of Matplotlib can be tested using simple unit tests, e.g. ::
127127
128128Data in tests
129129^^^^^^^^^^^^^
130- Try to use minimal explicit data. Often you can use explicit values like
131- ``[1, 2, 3] ``, ``range(5) `` or ``np.arange(5) ``. This is cheap and
130+ Try to use minimal explicit data, such as
131+ ``[1, 2, 3] ``, ``range(5) `` or ``np.arange(5) ``, because it
132132makes the test more readable.
133133
134134When you need more and non-trivial data, generate it programmatically, e.g. ::
135135
136136 x = np.linspace(0, 2*np.pi, 101)
137137 y = 2 * np.sin(x) + 1
138138
139- Use random numbers only, if an algorihmical way to generate the data is not
140- possible or too cumbersome . In this case, set the seed to a fixed value to make
139+ Use random numbers only when an algorithmic way to generate the data is too
140+ cumbersome or impossible . In this case, set the seed to a fixed value to make
141141the test deterministic. For numpy's default random number generator use ::
142142
143143 import numpy as np
@@ -149,9 +149,10 @@ The seed is :ref:`John Hunter's <project_history>` birthday.
149149
150150Test cleanup
151151^^^^^^^^^^^^
152- We often need figures or modify `.rcParams ` to test some functionality. Cleanup
153- of such side effects is handled automatically through the the pytest fixture
154- ``matplotlib.testing.conftest.mpl_test_settings ``.
152+ We often need to create figures or to modify `.rcParams ` to test some functionality.
153+ Cleanup of such side effects is handled automatically through a pytest fixture
154+ (``matplotlib.testing.conftest.mpl_test_settings ``) so that no manual cleanup is
155+ necessary.
155156
156157In particular, you don't need to call ``plt.close() ``.
157158
@@ -182,7 +183,7 @@ and asserts in one test, e.g.::
182183 assert mcolors.same_color(coll.get_facecolor(), fcolor)
183184
184185Assert values rather than visual results when feasible. This is clearer,
185- less expensive and less fragile than comparing images, e.g. ::
186+ less computationally expensive and less fragile than comparing images, e.g. ::
186187
187188 def test_savefig_preserve_layout_engine():
188189 fig = plt.figure(layout='compressed')
0 commit comments