|
def | init () |
|
def | run (suite, exit=True) |
| Exit with the status code resulting from running the provided test suite. More...
|
|
def | sort_tests (tests) |
| Go through the supplied sequence of test suites and sort them to ensure that MemoryTestCases are at the end of the test list. More...
|
|
def | suiteClassWrapper (tests) |
|
def | findFileFromRoot (ifile) |
| Find file which is specified as a path relative to the toplevel directory; we start in $cwd and walk up until we find the file (or throw IOError if it doesn't exist) More...
|
|
def | getTempFilePath (ext, expectOutput=True) |
| Return a path suitable for a temporary file and try to delete the file on success. More...
|
|
def | inTestCase (func) |
| A decorator to add a free function to our custom TestCase class, while also making it available as a free function. More...
|
|
def | assertRaisesLsstCpp (testcase, excClass, callableObj, args, kwargs) |
|
def | debugger (exceptions) |
| Decorator to enter the debugger when there's an uncaught exception. More...
|
|
def | plotImageDiff (lhs, rhs, bad=None, diff=None, plotFileName=None) |
| Plot the comparison of two 2-d NumPy arrays. More...
|
|
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) |
| Highly-configurable floating point comparisons for scalars and arrays. More...
|
|
def | assertFloatsNotEqual (testCase, lhs, rhs, kwds) |
|
def | assertFloatsEqual (testCase, lhs, rhs, kwargs) |
|
def | assertClose (args, kwargs) |
|
def | assertNotClose (args, kwargs) |
|
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
-
[in] | testCase | unittest.TestCase instance the test is part of |
[in] | lhs | LHS value(s) to compare; may be a scalar or array-like of any dimension |
[in] | rhs | RHS value(s) to compare; may be a scalar or array-like of any dimension |
[in] | rtol | Relative tolerance for comparison; defaults to double-precision epsilon. |
[in] | atol | Absolute tolerance for comparison; defaults to double-precision epsilon. |
[in] | relTo | Value to which comparison with rtol is relative. |
[in] | printFailures | Upon failure, print all inequal elements as part of the message. |
[in] | plotOnFailure | Upon failure, plot the originals and their residual with matplotlib. Only 2-d arrays are supported. |
[in] | plotFileName | Filename to save the plot to. If None, the plot will be displayed in a a window. |
[in] | invert | If True, invert the comparison and fail only if any elements are equal. Used to implement assertFloatsNotEqual, which should generally be used instead for clarity. |
[in] | msg | String to append to the error message when assert fails. |
Definition at line 550 of file tests.py.
def lsst.utils.tests.debugger |
( |
|
exceptions | ) |
|
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
-
[in] | ext | file name extension, e.g. ".fits" |
[in] | expectOutput | If true, a file should be created within the context manager. If false, a file should not be present when the context manager is exited. |
- Returns
- path for a temporary file. The path is a combination of the caller's file path and the name of the top-level function, as per this simple example:
import unittest
class FooTestCase(unittest.TestCase):
def testBasics(self):
self.runTest()
def runTest(self):
...
...
Definition at line 358 of file tests.py.