Control¶
-
class
lsst.sconsUtils.tests.
Control
(env, ignoreList=None, expectedFailures=None, args=None, tmpDir='.tests', verbose=False)¶ Bases:
object
A class to control and run unit tests.
This class is unchanged from previous versions of sconsUtils, but it will now generally be called via
lsst.sconsUtils.scripts.BasicSConscript.tests
.Parameters: - env :
SCons.Environment
An SCons Environment (almost always
lsst.sconsUtils.env
).- ignoreList :
list
, optional A list of tests that should NOT be run — useful in conjunction with glob patterns. If a file is listed as “@fileName”, the @ is stripped and we don’t bother to check if fileName exists (useful for machine-generated files).
- expectedFailures :
dict
, optional A dictionary; the keys are tests that are known to fail; the values are strings to print.
- args :
dict
, optional A dictionary with testnames as keys, and argument strings as values. As scons always runs from the top-level directory, tests has to fiddle with paths. If an argument is a file this is done automatically; if it’s e.g., just a basename then you have to tell tests that it’s really (part of a) filename by prefixing the name by
file:
.- tmpDir :
str
, optional The location of the test outputs.
- verbose :
bool
, optional How chatty you want the test code to be.
Notes
Sample usage:
tests = lsst.tests.Control( env, args={ "MaskIO_1" : "data/871034p_1_MI_msk.fits", "MaskedImage_1" : "file:data/871034p_1_MI foo", }, ignoreList=["Measure_1"], expectedFailures={"BBox_1": "Problem with single-pixel BBox"} )
This class is unchanged from previous versions of sconsUtils, but it will now generally be called via
lsst.sconsUtils.scripts.BasicSConscript.tests
.Methods Summary
args
(test)Arguments to use for this test. ignore
(test)Should the test be ignored. junitPrefix
()Calculate the prefix to use for the JUnit output. messages
(test)Return the messages to be used in case of success/failure. run
(fileGlob)Create a test target for each file matching the supplied glob. runPythonTests
(pyList)Add a single target for testing all python files. Methods Documentation
-
args
(test)¶ Arguments to use for this test.
Parameters: - test :
str
Test file to be run.
Returns: - args :
str
The arguments as a single string. An empty string is returned if no arguments were specified in the constructor.
- test :
-
ignore
(test)¶ Should the test be ignored.
Parameters: - test :
str
The test target name.
Returns: - ignore :
bool
Whether the test should be ignored or not.
- test :
-
junitPrefix
()¶ Calculate the prefix to use for the JUnit output.
Returns: - prefix :
str
Prefix string to use.
Notes
Will use the EUPS product being built and the value of the
LSST_JUNIT_PREFIX
environment variable if that is set.- prefix :
-
messages
(test)¶ Return the messages to be used in case of success/failure.
Parameters: - test :
str
The test target.
Returns: - test :
-
run
(fileGlob)¶ Create a test target for each file matching the supplied glob.
Parameters: - fileGlob :
str
orSCons.Environment.Glob
File matching glob.
Returns: - targets :
Test target for each matching file.
- fileGlob :
-
runPythonTests
(pyList)¶ Add a single target for testing all python files.
Parameters: - pyList :
list
A list of nodes corresponding to python test files. The IgnoreList is respected when scanning for entries. If pyList is
None
, or an empty list, it uses automated test discovery within pytest. This differs from the behavior oflsst.sconsUtils.BasicSconscript.tests
where a distinction is made.
Returns: - target :
list
Returns a list containing a single target.
- pyList :
- env :