Testing#

The Testing module provides tools for testing the code. This might be part of the integration tests or unit tests.

assertions#

Functions asserting certain conditions are met (used e.g., in integration tests).

testing.assertions.assert_expected_output(file, expected_output)[source]#

Assert that the expected output is present in the sim_telarray file.

Parameters:
file: Path

Path to the sim_telarray file.

expected_output: dict

Expected output values.

testing.assertions.assert_file_type(file_type, file_name)[source]#

Assert that the file is of the given type.

Parameters:
file_type: str

File type (json, yaml).

file_name: str

File name.

testing.assertions.assert_n_showers_and_energy_range(file)[source]#

Assert the number of showers and the energy range.

The number of showers should be consistent with the required one (up to 1% tolerance) and the energies simulated are required to be within the configured ones.

Parameters:
file: Path

Path to the sim_telarray file.

testing.assertions.check_output_from_sim_telarray(file, expected_output)[source]#

Check that the sim_telarray simulation result is reasonable and matches the expected output.

Parameters:
file: Path

Path to the sim_telarray file.

expected_output: dict

Expected output values.

Raises:
ValueError

If the file is not a zstd compressed file.

compare_output#

Compare application output to reference output.

testing.compare_output.compare_ecsv_files(file1, file2, tolerance=1e-05)[source]#

Compare two ecsv files.

The comparison is successful if:

  • same number of rows

  • numerical values in columns are close

Parameters:
file1: str

First file to compare

file2: str

Second file to compare

tolerance: float

Tolerance for comparing numerical values.

testing.compare_output.compare_files(file1, file2, tolerance=1e-05)[source]#

Compare two files of file type ecsv, json or yaml.

Parameters:
file1: str

First file to compare

file2: str

Second file to compare

tolerance: float

Tolerance for comparing numerical values.

Returns:
bool

True if the files are equal, False otherwise.

testing.compare_output.compare_json_or_yaml_files(file1, file2, tolerance=0.01)[source]#

Compare two json or yaml files.

Take into account float comparison for sim_telarray string-embedded floats.

Parameters:
file1: str

First file to compare

file2: str

Second file to compare

tolerance: float

Tolerance for comparing numerical values.

Returns:
bool

True if the files are equal, False otherwise.