diff --git a/src/caosadvancedtools/table_json_conversion/convert.py b/src/caosadvancedtools/table_json_conversion/convert.py index a8df7ec2482faeac5b7ec3d6fe3232ac638eaf5c..37c39aae91da39a9e7f027050b6bff97f85efc16 100644 --- a/src/caosadvancedtools/table_json_conversion/convert.py +++ b/src/caosadvancedtools/table_json_conversion/convert.py @@ -54,9 +54,9 @@ def _column_id_to_chars(num): return _column_id_to_chars(int(num / 26) - 1) + chr(int(num % 26) + 65) -def _format_exception_table(exceptions: list(tuple), worksheet_title: str, - column_names: Optional[dict, list] = None, - max_line_length: Optional[int] = 120) -> str: +def _format_exception_table(exceptions: list[tuple], worksheet_title: str, + column_names: Optional[Union[dict, list]] = None, + max_line_length: int = 120) -> str: """ Given a list of tuples containing a row and column number as well as an exception in that order, and the title of the current worksheet, returns @@ -77,7 +77,7 @@ def _format_exception_table(exceptions: list(tuple), worksheet_title: str, column_names[column_num] should return the name of column column_names. If given, exceptions will be clustered by column. - max_line_length: int + max_line_length: int, default=120 Soft cap for the line length of the resulting table Return @@ -382,7 +382,7 @@ class XLSXConverter: raise self._errors[(sheet.title, row_idx)] = kerr.definitions - if exceptions != []: + if exceptions: exception_table = _format_exception_table(exceptions, sheet.title, col_names) raise jsonschema.ValidationError(exception_table) diff --git a/unittests/table_json_conversion/data/simple_data_broken.xlsx b/unittests/table_json_conversion/data/simple_data_broken.xlsx index 361953f660f12cb37d979ff3b4c49895265131e3..0221570c942fc28f2b59a282f751781ff4a504fa 100644 Binary files a/unittests/table_json_conversion/data/simple_data_broken.xlsx and b/unittests/table_json_conversion/data/simple_data_broken.xlsx differ diff --git a/unittests/table_json_conversion/test_read_xlsx.py b/unittests/table_json_conversion/test_read_xlsx.py index 897cd10bfba2a99ee73c20aeb86ccdefb4e1e60b..8fbf8a2ab504d91ed0389243bf1f15f0bf20eea4 100644 --- a/unittests/table_json_conversion/test_read_xlsx.py +++ b/unittests/table_json_conversion/test_read_xlsx.py @@ -126,11 +126,14 @@ def test_wrong_datatype(): assert "J7" in line if "1.5 is not of type 'integer'" in line: assert "K7" in line + if "1.2345 is not of type 'integer'" in line: + assert "K8" in line # No additional type errors if "is not of type 'boolean'" in str(caught.value): # ToDo: Remove when boolean is fixed assert str(caught.value).count("is not of type") == 3 else: - assert str(caught.value).count("is not of type") == 2 + assert str(caught.value).count("is not of type") == 2 # FIXME when everything works as + # # expected, set correct number. def test_additional_column():