Skip to content

Debug messages for pytest assertion errors #540

@smartie2076

Description

@smartie2076

There are some pytests which are very difficult to fix when they fail. It would be helpful, if the assertion error was followed with a hint on where to look to fix the issue, like this

def test_input_folder_csv_files_have_required_parameters(input_folder):
    """
        Browse all folders which contains a {CSV_ELEMENTS} folder (defined as csv input folders)
        and verify the csv files they contain have all required parameters.
        For the special folder 'input_template', it is also tested that it does not have any
        extra parameters besides the required ones
    """
    comparison = compare_input_parameters_with_reference(input_folder, ext=CSV_EXT)
    if MISSING_PARAMETERS_KEY not in comparison:
        assert True
    else:
        for k in comparison[MISSING_PARAMETERS_KEY].keys():
            for el in comparison[MISSING_PARAMETERS_KEY][k]:
                assert el in EXTRA_CSV_PARAMETERS, f"Key {el} is not in {EXTRA_PARAMETERS_KEY}, but is in {MISSING_PARAMETERS_KEY} in the folder {input_folder}."

List of functions where the help is especially needed:

  • test_input_folder_csv_files_have_required_parameters (16d3e65)
  • test_input_folder_json_file_have_required_parameters (6dcb824)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions