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.
- env
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.
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.
Add a target for running the python linter.
runPythonTests
(pyList)Add a single target for testing all python files.
Methods Documentation
- 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.
- Returns:
- prefix
str
Prefix string to use.
- prefix
Notes
Will use the EUPS product being built and the value of the
LSST_JUNIT_PREFIX
environment variable if that is set.
- 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.
- Parameters:
- fileGlob
str
orSCons.Environment.Glob
File matching glob.
- fileGlob
- Returns:
- targets
Test target for each matching file.
- runPythonLinter()¶
Add a target for running the python linter.
- Returns:
- target
list
Returns a list containing a single target. Can be empty if no suitable linter configuration was found.
- target
- 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.
- pyList
- Returns:
- target
list
Returns a list containing a single target.
- target