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:
envSCons.Environment

An SCons Environment (almost always lsst.sconsUtils.env).

ignoreListlist, 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).

expectedFailuresdict, optional

A dictionary; the keys are tests that are known to fail; the values are strings to print.

argsdict, 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:.

tmpDirstr, optional

The location of the test outputs.

verbosebool, 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:
teststr

Test file to be run.

Returns:
argsstr

The arguments as a single string. An empty string is returned if no arguments were specified in the constructor.

ignore(test)

Should the test be ignored.

Parameters:
teststr

The test target name.

Returns:
ignorebool

Whether the test should be ignored or not.

junitPrefix()

Calculate the prefix to use for the JUnit output.

Returns:
prefixstr

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.

messages(test)

Return the messages to be used in case of success/failure.

Parameters:
teststr

The test target.

Returns:
messagestuple

A tuple containing four strings: whether the test should pass (as a value “true” or “false”) and the associated message, and whether the test should fail and the associated message.

run(fileGlob)

Create a test target for each file matching the supplied glob.

Parameters:
fileGlobstr or SCons.Environment.Glob

File matching glob.

Returns:
targets

Test target for each matching file.

runPythonTests(pyList)

Add a single target for testing all python files.

Parameters:
pyListlist

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 of lsst.sconsUtils.BasicSconscript.tests where a distinction is made.

Returns:
targetlist

Returns a list containing a single target.