[yt-svn] commit/yt-doc: 3 new changesets
Bitbucket
commits-noreply at bitbucket.org
Thu Feb 14 13:06:41 PST 2013
3 new commits in yt-doc:
https://bitbucket.org/yt_analysis/yt-doc/commits/4d0c15e6fe2a/
changeset: 4d0c15e6fe2a
user: MatthewTurk
date: 2013-02-14 21:51:20
summary: Adding information about unit tests.
affected #: 1 file
diff -r 61f98cfe4aaf7669f0305204ed8b6bbfac87fcb2 -r 4d0c15e6fe2a02321e0fe11e03c0e38241701dc0 source/advanced/testing.rst
--- a/source/advanced/testing.rst
+++ b/source/advanced/testing.rst
@@ -28,6 +28,13 @@
What do Unit Tests Do
^^^^^^^^^^^^^^^^^^^^^
+Unit tests are tests that operate on some small set of machinery, and verify
+that the machinery works. yt uses the `Nose
+<http://nose.readthedocs.org/en/latest/>`_ framework for running unit tests.
+In practice, what this means is that we write scripts that ``yield``
+assertions, and Nose identifies those scripts, runs them, and verifies that the
+assertions are true.
+
How to Run Unit Tests
^^^^^^^^^^^^^^^^^^^^^
@@ -43,7 +50,8 @@
If you want to specify a specific unit test to run (and not run the entire
suite), you can do so by specifying the path of the test relative to the
-``$YT_DEST/src/yt-hg/yt`` directory. For example, if you want to run the
+``$YT_DEST/src/yt-hg/yt`` directory -- note that you strip off one ``yt`` more
+than you normally would! For example, if you want to run the
plot_window tests, you'd run:
.. code-block:: bash
@@ -53,6 +61,39 @@
How to Write Unit Tests
^^^^^^^^^^^^^^^^^^^^^^^
+yt provides several pieces of testing assistance, all in the ``yt.testing``
+module. Describing them in detail is somewhat outside the scope of this
+document, as in some cases they belong to other packages. However, a few come
+in handy:
+
+ * :func:`yt.testing.fake_random_pf` provides the ability to create a random parameter file,
+ with several fields and divided into several different grids, that can be
+ operated on.
+ * :func:`yt.testing.assert_equal` can operate on arrays.
+ * :func:`yt.testing.assert_almost_equal` can operate on arrays and accepts a relative
+ allowable difference.
+ * :func:`yt.testing.amrspace` provides the ability to create AMR grid structures.
+ * :func:`~yt.testing.expand_keywords` provides the ability to iterate over many values for
+ keywords.
+
+To create new unit tests:
+
+ #. Create a new ``tests/`` directory next to the file containing the
+ functionality you want to test.
+ #. Inside that directory, create a new python file prefixed with ``test_`` and
+ including the name of the functionality.
+ #. Inside that file, create one or more routines prefixed with ``test_`` that
+ accept no arguments. These should ``yield`` a set of values of the form
+ ``function``, ``arguments``. For example ``yield assert_equal, 1.0, 1.0``
+ would evaluate that 1.0 equaled 1.0.
+ #. Use ``fake_random_pf`` to test on parameter files, and be sure to test for
+ several combinations of ``nproc``, so that domain decomposition can be
+ tested as well.
+
+For an example of how to write unit tests, look at the file
+``yt/data_objects/tests/test_covering_grid.py``, which covers a great deal of
+functionality.
+
.. _answer_testing:
Answer Testing
https://bitbucket.org/yt_analysis/yt-doc/commits/881c2512f714/
changeset: 881c2512f714
user: MatthewTurk
date: 2013-02-14 22:03:14
summary: Adding note about expand_keywords
affected #: 1 file
diff -r 4d0c15e6fe2a02321e0fe11e03c0e38241701dc0 -r 881c2512f7145c558d6875b3d08586de8cf7ae0c source/advanced/testing.rst
--- a/source/advanced/testing.rst
+++ b/source/advanced/testing.rst
@@ -89,6 +89,9 @@
#. Use ``fake_random_pf`` to test on parameter files, and be sure to test for
several combinations of ``nproc``, so that domain decomposition can be
tested as well.
+ #. Test multiple combinations of options by using the
+ :func:`~yt.testing.expand_keywords` function, which will enable much
+ easier iteration over options.
For an example of how to write unit tests, look at the file
``yt/data_objects/tests/test_covering_grid.py``, which covers a great deal of
https://bitbucket.org/yt_analysis/yt-doc/commits/7368992b9651/
changeset: 7368992b9651
user: MatthewTurk
date: 2013-02-14 22:06:19
summary: Adding autosummary for testing infrastructure. (Thanks to Cameron for the
reminder.)
affected #: 1 file
diff -r 881c2512f7145c558d6875b3d08586de8cf7ae0c -r 7368992b965176f62a778545f86831a531d373e6 source/api/api.rst
--- a/source/api/api.rst
+++ b/source/api/api.rst
@@ -416,3 +416,32 @@
~yt.utilities.parallel_tools.parallel_analysis_interface.ObjectIterator
~yt.utilities.parallel_tools.parallel_analysis_interface.ParallelAnalysisInterface
~yt.utilities.parallel_tools.parallel_analysis_interface.ParallelObjectIterator
+
+Testing Infrastructure
+----------------------
+
+The first set of functions are all provided by NumPy.
+
+.. autosummary::
+ :toctree: generated/
+
+ ~yt.testing.assert_array_equal
+ ~yt.testing.assert_almost_equal
+ ~yt.testing.assert_approx_equal
+ ~yt.testing.assert_array_almost_equal
+ ~yt.testing.assert_equal
+ ~yt.testing.assert_array_less
+ ~yt.testing.assert_string_equal
+ ~yt.testing.assert_array_almost_equal_nulp
+ ~yt.testing.assert_allclose
+ ~yt.testing.assert_raises
+
+These are yt-provided functions:
+
+.. autosummary::
+ :toctree: generated/
+
+ ~yt.testing.assert_rel_equal
+ ~yt.testing.amrspace
+ ~yt.testing.fake_random_pf
+ ~yt.testing.expand_keywords
Repository URL: https://bitbucket.org/yt_analysis/yt-doc/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list