The SKIRT project
advanced radiative transfer for astrophysics
Classes | Functions
pts.test.functional Namespace Reference

Contains the SkirtTestSuite class for performing a suite of SKIRT test cases. More...

Classes

class  SkirtTestSuite
 An instance of the SkirtTestSuite class represents a suite of SKIRT test cases, stored as a nested structure of files and directories according to a specific layout, and provides facilities to perform the tests, verify the results, and prepare a summary test report. More...
 

Functions

def _areEqualFitsFiles (filePath1, filePath2)
 This helper function returns True if the specified FITS files are equal except for the information in a single header record, and False otherwise. More...
 
def _areEqualLists (list1, list2, allowedDiffs)
 This helper function returns True if the specified lists are equal except for the contents of a number of items not larger than allowedDiffs, and False otherwise. More...
 
def _readBlocks (filepath)
 This helper function reads blocks of 80 bytes from the specified binary file into a list of bytes objects, and returns the list. More...
 
def findDifferences (sim)
 This function looks for relevant differences between the contents of the output and reference directories of the test case represented by the specified simulation. More...
 
def getDifferenceStatistics (sim, name)
 This function returns a string describing some basic statistics on the difference between the reference and output files of the specified name in the specified simulation. More...
 
def reportTestCase (sim)
 This function verifies the results for the test case represented by the specified simulation, creates a test report in the output directory, and returns an overall status string: "Crashed", "Failed", or "Succeeded". More...
 

Detailed Description

Contains the SkirtTestSuite class for performing a suite of SKIRT test cases.

An instance of the SkirtTestSuite class in this module represents a suite of functional SKIRT test cases, stored as a nested structure of files and directories according to a specific layout, and provides facilities to perform the tests, verify the results, and prepare a summary test report.

Function Documentation

◆ _areEqualFitsFiles()

def pts.test.functional._areEqualFitsFiles (   filePath1,
  filePath2 
)
private

This helper function returns True if the specified FITS files are equal except for the information in a single header record, and False otherwise.

◆ _areEqualLists()

def pts.test.functional._areEqualLists (   list1,
  list2,
  allowedDiffs 
)
private

This helper function returns True if the specified lists are equal except for the contents of a number of items not larger than allowedDiffs, and False otherwise.

◆ _readBlocks()

def pts.test.functional._readBlocks (   filepath)
private

This helper function reads blocks of 80 bytes from the specified binary file into a list of bytes objects, and returns the list.

◆ findDifferences()

def pts.test.functional.findDifferences (   sim)

This function looks for relevant differences between the contents of the output and reference directories of the test case represented by the specified simulation.

The function returns three lists of file names, which should all be empty for the test case to be successful:

  • a list of extra files: files present in the output directory but not in the reference directory.
  • a list of missing files: files present in the reference directory but not in the output directory.
  • a list of differing files: files present in both directories but which have a different contents.

The function only handles files of the following types:

  • "*.dat": the contents of these files must be identical.
  • "*.fits": the contents of these files must be identical except for the information in one header line (allowing a different time stamp)

Any other files are ignored. Specifically, this means that the following file types are not compared:

  • the SKIRT log file ("*.log")
  • the parameter file generated by SKIRT ("*_parameters.xml")
  • visualization files generated by PTS ("*.pdf", "*.png")

◆ getDifferenceStatistics()

def pts.test.functional.getDifferenceStatistics (   sim,
  name 
)

This function returns a string describing some basic statistics on the difference between the reference and output files of the specified name in the specified simulation.

It supports text columns files and FITS files. Essentially, the string shows the number of nonzero values that don't match, that differ by more than 10 percent, and that differ by more than 50% between the files.

◆ reportTestCase()

def pts.test.functional.reportTestCase (   sim)

This function verifies the results for the test case represented by the specified simulation, creates a test report in the output directory, and returns an overall status string: "Crashed", "Failed", or "Succeeded".