LSSTApplications
17.0+11,17.0+34,17.0+56,17.0+57,17.0+59,17.0+7,17.0-1-g377950a+33,17.0.1-1-g114240f+2,17.0.1-1-g4d4fbc4+28,17.0.1-1-g55520dc+49,17.0.1-1-g5f4ed7e+52,17.0.1-1-g6dd7d69+17,17.0.1-1-g8de6c91+11,17.0.1-1-gb9095d2+7,17.0.1-1-ge9fec5e+5,17.0.1-1-gf4e0155+55,17.0.1-1-gfc65f5f+50,17.0.1-1-gfc6fb1f+20,17.0.1-10-g87f9f3f+1,17.0.1-11-ge9de802+16,17.0.1-16-ga14f7d5c+4,17.0.1-17-gc79d625+1,17.0.1-17-gdae4c4a+8,17.0.1-2-g26618f5+29,17.0.1-2-g54f2ebc+9,17.0.1-2-gf403422+1,17.0.1-20-g2ca2f74+6,17.0.1-23-gf3eadeb7+1,17.0.1-3-g7e86b59+39,17.0.1-3-gb5ca14a,17.0.1-3-gd08d533+40,17.0.1-30-g596af8797,17.0.1-4-g59d126d+4,17.0.1-4-gc69c472+5,17.0.1-6-g5afd9b9+4,17.0.1-7-g35889ee+1,17.0.1-7-gc7c8782+18,17.0.1-9-gc4bbfb2+3,w.2019.22
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.