|
LSSTApplications
16.0-10-g0ee56ad+5,16.0-11-ga33d1f2+5,16.0-12-g3ef5c14+3,16.0-12-g71e5ef5+18,16.0-12-gbdf3636+3,16.0-13-g118c103+3,16.0-13-g8f68b0a+3,16.0-15-gbf5c1cb+4,16.0-16-gfd17674+3,16.0-17-g7c01f5c+3,16.0-18-g0a50484+1,16.0-20-ga20f992+8,16.0-21-g0e05fd4+6,16.0-21-g15e2d33+4,16.0-22-g62d8060+4,16.0-22-g847a80f+4,16.0-25-gf00d9b8+1,16.0-28-g3990c221+4,16.0-3-gf928089+3,16.0-32-g88a4f23+5,16.0-34-gd7987ad+3,16.0-37-gc7333cb+2,16.0-4-g10fc685+2,16.0-4-g18f3627+26,16.0-4-g5f3a788+26,16.0-5-gaf5c3d7+4,16.0-5-gcc1f4bb+1,16.0-6-g3b92700+4,16.0-6-g4412fcd+3,16.0-6-g7235603+4,16.0-69-g2562ce1b+2,16.0-8-g14ebd58+4,16.0-8-g2df868b+1,16.0-8-g4cec79c+6,16.0-8-gadf6c7a+1,16.0-8-gfc7ad86,16.0-82-g59ec2a54a+1,16.0-9-g5400cdc+2,16.0-9-ge6233d7+5,master-g2880f2d8cf+3,v17.0.rc1
LSSTDataManagementBasePackage
|
Classes | |
| class | ExecutablesTestCase |
| class | MemoryTestCase |
| class | TestCase |
Functions | |
| def | init () |
| def | run (suite, exit=True) |
| def | sort_tests (tests) |
| def | suiteClassWrapper (tests) |
| def | getTempFilePath (ext, expectOutput=True) |
| def | inTestCase (func) |
| def | assertRaisesLsstCpp (testcase, excClass, callableObj, args, kwargs) |
| def | debugger (exceptions) |
| def | plotImageDiff (lhs, rhs, bad=None, diff=None, plotFileName=None) |
| def | assertFloatsAlmostEqual (testCase, lhs, rhs, rtol=sys.float_info.epsilon, atol=sys.float_info.epsilon, relTo=None, printFailures=True, plotOnFailure=False, plotFileName=None, invert=False, msg=None) |
| def | assertFloatsNotEqual (testCase, lhs, rhs, kwds) |
| def | assertFloatsEqual (testCase, lhs, rhs, kwargs) |
| def | assertClose (args, kwargs) |
| def | assertNotClose (args, kwargs) |
Variables | |
| psutil = None | |
| dafBase = None | |
| int | memId0 = 0 |
| int | nleakPrintMax = 20 |
| open_files = set() | |
| def lsst.utils.tests.assertClose | ( | args, | |
| kwargs | |||
| ) |
.. note:: Deprecated in 12_0
Definition at line 793 of file tests.py.
| def lsst.utils.tests.assertFloatsAlmostEqual | ( | testCase, | |
| lhs, | |||
| rhs, | |||
rtol = sys.float_info.epsilon, |
|||
atol = sys.float_info.epsilon, |
|||
relTo = None, |
|||
printFailures = True, |
|||
plotOnFailure = False, |
|||
plotFileName = None, |
|||
invert = False, |
|||
msg = None |
|||
| ) |
Highly-configurable floating point comparisons for scalars and arrays.
The test assertion will fail if all elements ``lhs`` and ``rhs`` are not
equal to within the tolerances specified by ``rtol`` and ``atol``.
More precisely, the comparison is:
``abs(lhs - rhs) <= relTo*rtol OR abs(lhs - rhs) <= atol``
If ``rtol`` or ``atol`` is `None`, that term in the comparison is not
performed at all.
When not specified, ``relTo`` is the elementwise maximum of the absolute
values of ``lhs`` and ``rhs``. If set manually, it should usually be set
to either ``lhs`` or ``rhs``, or a scalar value typical of what is
expected.
Parameters
----------
testCase : `unittest.TestCase`
Instance the test is part of.
lhs : scalar or array-like
LHS value(s) to compare; may be a scalar or array-like of any
dimension.
rhs : scalar or array-like
RHS value(s) to compare; may be a scalar or array-like of any
dimension.
rtol : `float`, optional
Relative tolerance for comparison; defaults to double-precision
epsilon.
atol : `float`, optional
Absolute tolerance for comparison; defaults to double-precision
epsilon.
relTo : `float`, optional
Value to which comparison with rtol is relative.
printFailures : `bool`, optional
Upon failure, print all inequal elements as part of the message.
plotOnFailure : `bool`, optional
Upon failure, plot the originals and their residual with matplotlib.
Only 2-d arrays are supported.
plotFileName : `str`, optional
Filename to save the plot to. If `None`, the plot will be displayed in
a window.
invert : `bool`, optional
If `True`, invert the comparison and fail only if any elements *are*
equal. Used to implement `~lsst.utils.tests.assertFloatsNotEqual`,
which should generally be used instead for clarity.
msg : `str`, optional
String to append to the error message when assert fails.
Raises
------
AssertionError
The values are not almost equal.
Definition at line 612 of file tests.py.
| def lsst.utils.tests.assertFloatsEqual | ( | testCase, | |
| lhs, | |||
| rhs, | |||
| kwargs | |||
| ) |
Assert that lhs == rhs (both numeric types, whether scalar or array).
See `~lsst.utils.tests.assertFloatsAlmostEqual` (called with
``rtol=atol=0``) for more information.
Parameters
----------
testCase : `unittest.TestCase`
Instance the test is part of.
lhs : scalar or array-like
LHS value(s) to compare; may be a scalar or array-like of any
dimension.
rhs : scalar or array-like
RHS value(s) to compare; may be a scalar or array-like of any
dimension.
Raises
------
AssertionError
The values are not equal.
Definition at line 766 of file tests.py.
| def lsst.utils.tests.assertFloatsNotEqual | ( | testCase, | |
| lhs, | |||
| rhs, | |||
| kwds | |||
| ) |
Fail a test if the given floating point values are equal to within the
given tolerances.
See `~lsst.utils.tests.assertFloatsAlmostEqual` (called with
``rtol=atol=0``) for more information.
Parameters
----------
testCase : `unittest.TestCase`
Instance the test is part of.
lhs : scalar or array-like
LHS value(s) to compare; may be a scalar or array-like of any
dimension.
rhs : scalar or array-like
RHS value(s) to compare; may be a scalar or array-like of any
dimension.
Raises
------
AssertionError
The values are almost equal.
Definition at line 739 of file tests.py.
| def lsst.utils.tests.assertNotClose | ( | args, | |
| kwargs | |||
| ) |
.. note:: Deprecated in 12_0
Definition at line 801 of file tests.py.
| def lsst.utils.tests.assertRaisesLsstCpp | ( | testcase, | |
| excClass, | |||
| callableObj, | |||
| args, | |||
| kwargs | |||
| ) |
.. note:: Deprecated in 12_0
Definition at line 503 of file tests.py.
| def lsst.utils.tests.debugger | ( | exceptions | ) |
Decorator to enter the debugger when there's an uncaught exception To use, just slap a ``@debugger()`` on your function. You may provide specific exception classes to catch as arguments to the decorator function, e.g., ``@debugger(RuntimeError, NotImplementedError)``. This defaults to just `AssertionError`, for use on `unittest.TestCase` methods. Code provided by "Rosh Oxymoron" on StackOverflow: http://stackoverflow.com/questions/4398967/python-unit-testing-automatically-running-the-debugger-when-a-test-fails Notes ----- Consider using ``pytest --pdb`` instead of this decorator.
| def lsst.utils.tests.getTempFilePath | ( | ext, | |
expectOutput = True |
|||
| ) |
Return a path suitable for a temporary file and try to delete the
file on success
If the with block completes successfully then the file is deleted,
if possible; failure results in a printed warning.
If a file is remains when it should not, a RuntimeError exception is
raised. This exception is also raised if a file is not present on context
manager exit when one is expected to exist.
If the block exits with an exception the file if left on disk so it can be
examined. The file name has a random component such that nested context
managers can be used with the same file suffix.
Parameters
----------
ext : `str`
File name extension, e.g. ``.fits``.
expectOutput : `bool`, optional
If `True`, a file should be created within the context manager.
If `False`, a file should not be present when the context manager
exits.
Returns
-------
`str`
Path for a temporary file. The path is a combination of the caller's
file path and the name of the top-level function
Notes
-----
::
# file tests/testFoo.py
import unittest
import lsst.utils.tests
class FooTestCase(unittest.TestCase):
def testBasics(self):
self.runTest()
def runTest(self):
with lsst.utils.tests.getTempFilePath(".fits") as tmpFile:
# if tests/.tests exists then
# tmpFile = "tests/.tests/testFoo_testBasics.fits"
# otherwise tmpFile = "testFoo_testBasics.fits"
...
# at the end of this "with" block the path tmpFile will be
# deleted, but only if the file exists and the "with"
# block terminated normally (rather than with an exception)
...
Definition at line 389 of file tests.py.
| def lsst.utils.tests.init | ( | ) |
| def lsst.utils.tests.inTestCase | ( | func | ) |
| def lsst.utils.tests.plotImageDiff | ( | lhs, | |
| rhs, | |||
bad = None, |
|||
diff = None, |
|||
plotFileName = None |
|||
| ) |
Plot the comparison of two 2-d NumPy arrays.
Parameters
----------
lhs : `numpy.ndarray`
LHS values to compare; a 2-d NumPy array
rhs : `numpy.ndarray`
RHS values to compare; a 2-d NumPy array
bad : `numpy.ndarray`
A 2-d boolean NumPy array of values to emphasize in the plots
diff : `numpy.ndarray`
difference array; a 2-d NumPy array, or None to show lhs-rhs
plotFileName : `str`
Filename to save the plot to. If None, the plot will be displayed in
a window.
Notes
-----
This method uses `matplotlib` and imports it internally; it should be
wrapped in a try/except block within packages that do not depend on
`matplotlib` (including `~lsst.utils`).
Definition at line 544 of file tests.py.
| def lsst.utils.tests.run | ( | suite, | |
exit = True |
|||
| ) |
Run a test suite and report the test return status to caller or shell.
.. note:: Deprecated in 13_0
Use `unittest.main()` instead, which automatically detects
all tests in a test case and does not require a test suite.
Parameters
----------
suite : `unittest.TestSuite`
Test suite to run.
exit : `bool`, optional
If `True`, Python process will exit with the test exit status.
Returns
-------
status : `int`
If ``exit`` is `False`, will return 0 if the tests passed, or 1 if
the tests failed.
Definition at line 85 of file tests.py.
| def lsst.utils.tests.sort_tests | ( | tests | ) |
Sort supplied test suites such that MemoryTestCases are at the end.
`lsst.utils.tests.MemoryTestCase` tests should always run after any other
tests in the module.
Parameters
----------
tests : sequence
Sequence of test suites.
Returns
-------
suite : `unittest.TestSuite`
A combined `~unittest.TestSuite` with
`~lsst.utils.tests.MemoryTestCase` at the end.
Definition at line 120 of file tests.py.
1.8.13