API

Test

class mats.Test(moniker, min_value=None, max_value=None, pass_if=None, loglevel=20)

A test is the most basic unit of an executing test sequence. Within a test, we may have a setup(), execute(), and teardown() method. Only the execute() method is required to be overridden.

Parameters:
  • moniker – a shortcut name for this particular test
  • min_value – the minimum value that is to be considered a pass, if defined
  • max_value – the maximum value that is to be considered a pass, if defined
  • pass_if – the value that must be present in order to pass, if defined
  • loglevel – the logging level to apply such as logging.INFO
execute(is_passing)

Abstract method intended to be overridden by subclass

Parameters:is_passing – True if the test sequence is passing up to this point, else False
Returns:value to be appended to the sequence dictionary
fail()

When called, will cause the test to fail.

Returns:None
reset()

Reset the test status :return: None

save_dict(data: dict)

Allows a test to save additional data other than that returned by execute()

Parameters:data – key: value pairs of the data to be stored
Returns:None
setup(is_passing)

Abstract method intended to be overridden by subclass

Parameters:is_passing – True if the test sequence is passing up to this point, else False
Returns:None
teardown(is_passing)

Abstract method intended to be overridden by subclass

Parameters:is_passing – True if the test sequence is passing up to this point, else False
Returns:None

TestSequence

class mats.TestSequence(sequence: List[mats.test.Test], archive_manager: mats.archiving.ArchiveManager = None, auto_start=False, auto_run=False, callback: callable = None, setup: callable = None, teardown: callable = None, loglevel=20)

The TestSequence will “knit” the sequence together by taking the test objects and appropriately passing them through the automated testing process.

Parameters:
  • sequence – a list of Tests
  • archive_manager – an instance of ArchiveManager which will contain the path and format-specific information
  • auto_start – True if test is to be automatically started
  • auto_run – True if the test is to be continually executed
  • callback – function to call on each test sequence completion; callback will be required to accept one parameter, which is the dictionary of values collected over that test iteration
  • setup – function to call before the test sequence
  • teardown – function to call after the test sequence is complete, even if there was a problem; common to have safety issues addressed here
  • loglevel – the logging level
abort()

Abort the current test sequence.

Returns:None
failed_tests

Return a list of the tests which failed.

Returns:list of tests that failed
is_aborted

Returns True if the test sequence has been aborted, else False

Returns:True or False
is_passing

Returns True if the test sequence is currently passing, else False

Returns:True or False
progress

Returns a tuple containing (current_test_number, total_tests) in order to give an indication of the progress of the test sequence.

Returns:tuple containing (current_test_number, total_tests)
ready

Returns True if the test sequence is ready for another go at it, False if not

Returns:True or False
start()

Start a test sequence. Will only work if a test sequence isn’t already in progress.

Returns:None
test_names

Returns the names of the tests contained within the TestSequence

Returns:the names of the tests as a list
tests

Returns instances of all tests contained within the TestSequence

Returns:all tests as a list

ArchiveManager

class mats.ArchiveManager(path='.', fname='data', fextension='.csv', delimiter='t', loglevel=20)
save(point: dict)

Takes a point of data supplied as a dict and, depending on existing conditions, will archive the data point on the disk. Three conditions possible at save time:

  • Data file does not exist
  • Data file exists and is compatible with the current data point (the header strings match)
  • Data file exists, but is not compatible with the current data point (the header strings do not match)

When the data file does not exist, then the save() method will create the new data file at <fname>.<extension>.

When the data file exists at <fname>.<extension> and is compatible with the current data point, then the save() method will simply append the new data point to previous data in a tabular format.

Finally, when the current data point is deemed incompatible with the previous data, then the save() method will copy the old file to <fname>_<datetime>.<extension> and then create a new file at <fname>.<extension> under which data will be collected until a new format is once again detected.

Parameters:point – a dict containing key: value pairs which specify the data to be saved
Returns:None

gui.tk.MatsFrame