armi.tests package
General framework-wide testing functions and files.
This package contains some input files that can be used across a wide variety of unit tests in other lower-level subpackages.
- armi.tests.getEmptyCartesianReactor(pitch=(10.0, 16.0))[source]
Return an empty Cartesian reactor used in some tests.
- class armi.tests.Fixture(refDirectory, targets, dependencies, function)[source]
Bases:
object
Fixture for presenting a consistent data source for testing.
A Fixture is a class that wraps a function which generates resources needed by one or more tests that doesn’t need to be updated every time tests are run.
Do not use this class directly, instead use the
@fixture
and@requires_fixture
decorators.
- armi.tests.fixture(refDirectory=None, targets=None, dependencies=None)[source]
Decorator to run function based on targets and dependencies similar to GNU Make.
- Parameters:
refDirectory (str) – String reference directory for all targets/dependencies. This makes it possible to simplify file paths. If
os.path.abspath(<path>) == <path>
, then refDirectory is not used.targets (iterable(str)) – List of targets that the function generates.
dependencies (iterable(str)) – List of dependencies that the
targets
require.
- armi.tests.requires_fixture(fixtureFunction)[source]
Decorator to require a fixture to have been completed.
- Parameters:
fixtureFunction (function without any parameters) – Fixture function is a function that has been decorated with fixture and is called prior to running the decorated function.
Notes
This cannot be used on classes.
- class armi.tests.ArmiTestHelper(methodName='runTest')[source]
Bases:
TestCase
Class containing common testing methods shared by many tests.
Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
- compareFilesLineByLine(expectedFilePath, actualFilePath, falseNegList=None, eps=None)[source]
Compare the contents of two files line by line.
Warning
The file located at actualFilePath will be deleted if they do match.
Some tests write text files that should be compared line-by-line with reference files. This method performs the comparison.
This class of test is not ideal but does cover a lot of functionality quickly. To assist in the maintenance burden, the following standards are expected and enforced:
The reference file compared against will be called either
[name]-ref.[ext]
or[name].expected
.The file that the test creates will be called
[name]-test.[ext]
or[name]
.
Rebaselining the reference files upon large, expected, hand-verified changes is accomodated by
rebaselineTextComparisons()
.- Parameters:
expectedFilePath (str) – Path to the reference or expected file
actualFilePath (str) – Path to the file that will be compared to
expectedFilePath
falseNegList (None or Iterable) – Optional argument. If two lines are not equal, then check if any values from
falseNegList
are in this line. If so, do not fail the test.eps (float, optional) – If provided, try to determine if the only difference between compared lines is in the value of something that can be parsed into a float, and the relative difference between the two floats is below the passed epsilon.
- static compareLines(actual: str, expected: str, eps: Optional[float] = None)[source]
Impl of line comparison for compareFilesLineByLine.
if rstripped lines are equal -> Good. Otherwise, split on whitespace and try to parse element pairs as floats. if they are both parsable, compare with relative eps, if provided. A side effect of the epsilon comparison is that differing whitespace between words is treated as irrelevant.
- armi.tests.rebaselineTextComparisons(root)[source]
Rebaseline test line-by-line comparison files.
This scans the source tree for failed unit test file comparisons (indicated by the presence of, for example, a
-test.inp
and a-ref.inp
file) and moves the test one to the reference one. The work done can be reviewed/approved in source management.This is convenient when a large-scope change is made, such as updating the properties of a commonly-used material.
Submodules
- armi.tests.mockRunLogs module
- armi.tests.refSmallReactorShuffleLogic module
- armi.tests.test_apps module
TestPlugin1
TestPlugin2
TestPlugin3
TestPlugin4
TestApps
TestApps.test_getParamRenames()
TestApps.test_registerPluginFlags()
TestApps.test_getParamRenamesInvalids()
TestApps.test_version()
TestApps.test_getSettings()
TestApps.test_splashText()
TestApps.test_splashTextDifferentApp()
TestApps.test_isStableReleaseVersion()
TestApps.test_disableFutureConfigures()
TestArmi
- armi.tests.test_armiTestHelper module
- armi.tests.test_cartesian module
- armi.tests.test_interfaces module
DummyInterface
TestCodeInterface
TestTextProcessor
TestTightCoupler
TestTightCoupler.test_couplerActive()
TestTightCoupler.test_storePreviousIterationValue()
TestTightCoupler.test_storePreviousIterationValueException()
TestTightCoupler.test_isConvergedValueError()
TestTightCoupler.test_isConverged()
TestTightCoupler.test_isConvergedRuntimeError()
TestTightCoupler.test_getListDimension()
- armi.tests.test_lwrInputs module
- armi.tests.test_mpiActions module
MpiIterTests
MpiIterTests.test_parallel()
MpiIterTests.test_serialGather()
MpiIterTests.test_mpiIter()
MpiIterTests.test_perfectBalancing()
MpiIterTests.test_excessProcesses()
MpiIterTests.test_typicalBalancing()
MpiIterTests.test_runActionsDistributionAction()
MpiIterTests.test_runActionsDistributeStateAction()
MpiIterTests.test_diagnosePickleErrorTestReactor()
QueueActionsTests
passer()
- armi.tests.test_mpiFeatures module
- armi.tests.test_notebooks module
- armi.tests.test_plugins module
- armi.tests.test_runLog module
TestRunLog
TestRunLog.test_setVerbosityFromInteger()
TestRunLog.test_setVerbosityFromString()
TestRunLog.test_verbosityOutOfRange()
TestRunLog.test_invalidSetVerbosityByString()
TestRunLog.test_parentRunLogging()
TestRunLog.test_getWhiteSpace()
TestRunLog.test_warningReport()
TestRunLog.test_warningReportInvalid()
TestRunLog.test_closeLogging()
TestRunLog.test_setVerbosity()
TestRunLog.test_setVerbosityBeforeStartLog()
TestRunLog.test_callingStartLogMultipleTimes()
TestRunLog.test_concatenateLogs()
TestRunLog.test_createLogDir()
TestRunLogger
- armi.tests.test_tests module
- armi.tests.test_user_plugins module
UserPluginFlags
UserPluginFlags2
UserPluginFlags3
UserPluginBadDefinesSettings
UserPluginBadDefineParameterRenames
UserPluginOnProcessCoreLoading
UpInterface
UserPluginWithInterface
TestUserPlugins
TestUserPlugins.test_userPluginsFlags()
TestUserPlugins.test_validateUserPluginLimitations()
TestUserPlugins.test_registerUserPlugins()
TestUserPlugins.test_registerUserPluginsAbsPath()
TestUserPlugins.test_registerUserPluginsFromSettings()
TestUserPlugins.test_userPluginOnProcessCoreLoading()
TestUserPlugins.test_userPluginWithInterfaces()
TestUserPlugins.test_registerRepeatedUserPlugins()