Astropy Testing Tools¶
This section is primarily a reference for developers that want to understand or add to the Astropy testing machinery. See Testing Guidelines for an overview of running or writing the tests.
To ease development of tests that work with Astropy, the
astropy.tests.helper module provides some utility functions to make
tests that use Astropy conventions or classes easier to work with. e.g.,
functions to test for near-equality of
The functionality here is not exhaustive, because much of the useful tools are either in the standard library, py.test, or numpy.testing. This module contains primarily functionality specific to Astropy or affiliated packages that follow the package template.
Note that this module also includes the
remote_data marker, which
is used to indicate a test accesses data from the internet while running.
It is intended to be used as:
from astropy.tests.helper import remote_data @remote_data def test_something(): """ This test downloads something from the internet """ # test code here ...
This test will now only run if the test suite is invoked as
python setup.py test --remote-data.
||Turn on the feature that turns deprecations into exceptions.|
||Turn all DeprecationWarnings (which indicate deprecated uses of Python itself or Numpy, but not within Astropy, where we use our own deprecation warning class) into exceptions so that we find out about them early.|
||Test that an object follows our Unicode policy.|
||Returns True if two arrays are element-wise equal within a tolerance.|
||Raise an assertion if two objects are not equal up to desired tolerance.|
||Try to pickle an object.|
||Fixture to run all the tests for protocols 0 and 1, and -1 (most advanced).|
||Check if the attributes of a and b are equal.|
Astropy Test Runner¶
TestRunner class is used to generate the
astropy.test function, the test function generates a set of command line
arguments to pytest. The arguments to pytest are defined in the
run_tests method, the arguments to
run_tests and their respective logic are defined in methods of
TestRunner decorated with the
keyword decorator. For an example of this see
TestRunnerBase. This design makes it easy for affiliated
packages to add or remove keyword arguments to their test runners, or define a
whole new set of arguments by subclassing from