diff --git a/src/pvframework/execution.py b/src/pvframework/execution.py index c7c7c6e..91492c6 100644 --- a/src/pvframework/execution.py +++ b/src/pvframework/execution.py @@ -10,7 +10,7 @@ from dataclasses import dataclass from datetime import timedelta from enum import IntEnum, StrEnum -from io import StringIO +from io import SEEK_END, StringIO from typing import Generic, Iterable, Iterator, Optional import networkx as nx @@ -167,6 +167,7 @@ def get_csv_formatted_validator_infos( """ if initial_value is None or isinstance(initial_value, str): output = StringIO(initial_value=initial_value) + output.seek(0, SEEK_END) else: output = initial_value csv_writer = csv.writer(output) diff --git a/unittests/test_validation.py b/unittests/test_validation.py index bdd9f0f..13d941a 100644 --- a/unittests/test_validation.py +++ b/unittests/test_validation.py @@ -555,12 +555,23 @@ def test_validator_info_table(self): csv_table = validation_manager.get_csv_formatted_validator_infos() + validation_manager2 = ValidationManager[DataSetTest](manager_id="TestValidationManager2") + validation_manager2.register(PathMappedValidator(validator_check_y_positive, {"y": "y"})) + validation_manager2.register( + PathMappedValidator(validator_check_required_and_optional_with_utility, {"z": "z"}), + mode=ValidationMode.WARNING, + ) + + csv_table = validation_manager.get_csv_formatted_validator_infos() + csv_table = validation_manager2.get_csv_formatted_validator_infos(headings=None, initial_value=csv_table) + assert isinstance(csv_table, str) assert ( "Just a heavy task to validate x.\\n" "This docstring is used to test the output of the csv renderer of the ValidationManager." ) in csv_table assert "TestValidationManager" in csv_table + assert "TestValidationManager2" in csv_table assert "check_x_expensive" in csv_table assert ValidationMode.ERROR.value in csv_table assert ValidationMode.WARNING.value in csv_table