@@ -65,12 +65,29 @@ example, here is a test from :mod:`matplotlib.tests.test_basic`::
6565 from nose.tools import assert_equal
6666
6767 def test_simple():
68- '''very simple example test'''
68+ """
69+ very simple example test
70+ """
6971 assert_equal(1+1,2)
7072
7173Nose determines which functions are tests by searching for functions
7274beginning with "test" in their name.
7375
76+ If the test as side effects that need to be cleaned up, such as
77+ creating figures using the pyplot interface, use the ``@cleanup ``
78+ decorator::
79+
80+ from matplotlib.testing.decorators import cleanup
81+
82+ @cleanup
83+ def test_create_figure():
84+ """
85+ very simple example test that creates a figure using pyplot.
86+ """
87+ fig = figure()
88+ ...
89+
90+
7491Writing an image comparison test
7592--------------------------------
7693
@@ -146,27 +163,31 @@ fail condition, which can be a value such as True, False, or
146163Creating a new module in matplotlib.tests
147164-----------------------------------------
148165
149- Let's say you've added a new module named
150- ``matplotlib.tests.test_whizbang_features ``. To add this module to
151- the list of default tests, append its name to ``default_test_modules ``
152- in :file: `lib/matplotlib/__init__.py `.
166+ We try to keep the tests categorized by the primary module they are
167+ testing. For example, the tests related to the ``mathtext.py `` module
168+ are in ``test_mathtext.py ``.
169+
170+ Let's say you've added a new module named ``whizbang.py `` and you want
171+ to add tests for it in ``matplotlib.tests.test_whizbang ``. To add
172+ this module to the list of default tests, append its name to
173+ ``default_test_modules `` in :file: `lib/matplotlib/__init__.py `.
153174
154175Using tox
155176---------
156177
157- `Tox <http://tox.testrun.org/ >`_ is a tool for running tests against multiple
158- Python environments, including multiple versions of Python (e.g.: 2.6, 2.7,
159- 3.2, etc.) and even different Python implementations altogether (e.g.: CPython,
160- PyPy, Jython, etc.)
178+ `Tox <http://tox.testrun.org/ >`_ is a tool for running tests against
179+ multiple Python environments, including multiple versions of Python
180+ (e.g.: 2.6, 2.7, 3.2, etc.) and even different Python implementations
181+ altogether (e.g.: CPython, PyPy, Jython, etc.)
161182
162- Testing all 4 versions of Python (2.6, 2.7, 3.1, and 3.2) requires having four
163- versions of Python installed on your system and on the PATH. Depending on your
164- operating system, you may want to use your package manager (such as apt-get,
165- yum or MacPorts) to do this, or use ` pythonbrew
166- <https://github.com/utahta/pythonbrew> `_.
183+ Testing all 4 versions of Python (2.6, 2.7, 3.1, and 3.2) requires
184+ having four versions of Python installed on your system and on the
185+ PATH. Depending on your operating system, you may want to use your
186+ package manager (such as apt-get, yum or MacPorts) to do this, or use
187+ ` pythonbrew <https://github.com/utahta/pythonbrew >`_.
167188
168- tox makes it easy to determine if your working copy introduced any regressions
169- before submitting a pull request. Here's how to use it:
189+ tox makes it easy to determine if your working copy introduced any
190+ regressions before submitting a pull request. Here's how to use it:
170191
171192.. code-block :: bash
172193
@@ -179,40 +200,47 @@ You can also run tox on a subset of environments:
179200
180201 $ tox -e py26,py27
181202
182- Tox processes everything serially so it can take a long time to test several
183- environments. To speed it up, you might try using a new, parallelized version
184- of tox called ``detox ``. Give this a try:
203+ Tox processes everything serially so it can take a long time to test
204+ several environments. To speed it up, you might try using a new,
205+ parallelized version of tox called ``detox ``. Give this a try:
185206
186207.. code-block :: bash
187208
188209 $ pip install -U -i http://pypi.testrun.org detox
189210 $ detox
190211
191- Tox is configured using a file called ``tox.ini ``. You may need to edit this
192- file if you want to add new environments to test (e.g.: ``py33 ``) or if you
193- want to tweak the dependencies or the way the tests are run. For more info on
194- the ``tox.ini `` file, see the `Tox Configuration Specification
212+ Tox is configured using a file called ``tox.ini ``. You may need to
213+ edit this file if you want to add new environments to test (e.g.:
214+ ``py33 ``) or if you want to tweak the dependencies or the way the
215+ tests are run. For more info on the ``tox.ini `` file, see the `Tox
216+ Configuration Specification
195217<http://tox.testrun.org/latest/config.html> `_.
196218
197219Using Travis CI
198220---------------
199221
200- `Travis CI <http://travis-ci.org/ >`_ is a hosted CI system "in the cloud".
222+ `Travis CI <http://travis-ci.org/ >`_ is a hosted CI system "in the
223+ cloud".
201224
202- Travis is configured to receive notifications of new commits to GitHub repos
203- (via GitHub "service hooks") and to run builds or tests when it sees these new
204- commits. It looks for a YAML file called ``.travis.yml `` in the root of the
205- repository to see how to test the project.
225+ Travis is configured to receive notifications of new commits to GitHub
226+ repos (via GitHub "service hooks") and to run builds or tests when it
227+ sees these new commits. It looks for a YAML file called
228+ ``.travis.yml `` in the root of the repository to see how to test the
229+ project.
206230
207- Travis CI is already enabled for the `main matplotlib GitHub repository
208- <https://github.com/matplotlib/matplotlib/> `_ -- for example, see `its Travis
209- page <http://travis-ci.org/#!/matplotlib/matplotlib> `_.
231+ Travis CI is already enabled for the `main matplotlib GitHub
232+ repository <https://github.com/matplotlib/matplotlib/> `_ -- for
233+ example, see `its Travis page
234+ <http://travis-ci.org/#!/matplotlib/matplotlib> `_.
210235
211- If you want to enable Travis CI for your personal matplotlib GitHub repo,
212- simply enable the repo to use Travis CI in either the Travis CI UI or the
213- GitHub UI (Admin | Service Hooks). For details, see `the Travis CI Getting
214- Started page <http://about.travis-ci.org/docs/user/getting-started/> `_.
236+ If you want to enable Travis CI for your personal matplotlib GitHub
237+ repo, simply enable the repo to use Travis CI in either the Travis CI
238+ UI or the GitHub UI (Admin | Service Hooks). For details, see `the
239+ Travis CI Getting Started page
240+ <http://about.travis-ci.org/docs/user/getting-started/> `_. This
241+ generally isn't necessary, since any pull request submitted against
242+ the main matplotlib repository will be tested.
215243
216244Once this is configured, you can see the Travis CI results at
217- http://travis-ci.org/#!/your_GitHub_user_name/matplotlib -- here's `an example
218- <http://travis-ci.org/#!/msabramo/matplotlib> `_.
245+ http://travis-ci.org/#!/your_GitHub_user_name/matplotlib -- here's `an
246+ example <http://travis-ci.org/#!/msabramo/matplotlib> `_.
0 commit comments