Skip to content

Commit

Permalink
more test cases, modified error message
Browse files Browse the repository at this point in the history
  • Loading branch information
jxnior01 committed Jul 13, 2023
1 parent ebc1261 commit ac8ccb0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/safeds/exceptions/_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ class _UnknownColumnNameErrorMessage(
def __repr__(self) -> str:
return str(self)

super().__init__(
_UnknownColumnNameErrorMessage(
f"Could not find column(s) '{', '.join(column_names)}'.\nDid you mean '{similar_columns}'?",
),
)
error_message = f"Could not find column(s) '{', '.join(column_names)}'."

if similar_columns is not None:
error_message += f"\nDid you mean '{similar_columns}'?"

super().__init__(_UnknownColumnNameErrorMessage(error_message))


class NonNumericColumnError(Exception):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,19 @@
"clumn1",
["column1", "cilumn2"],
),
(
Table({"column1": ["col1_1"], "x": ["y"], "cilumn2": ["cil2_1"]}),
"notexisting",
["x"],
),
(
Table({"column1": ["col1_1"], "x": ["y"], "cilumn2": ["cil2_1"]}),
"x",
["x"],
),
(Table({}), "column1", []),
],
ids=["one similar", "two similar/ dynamic increase"],
ids=["one similar", "two similar/ dynamic increase", "no similar", "exact match", "empty table"],
)
def test_should_get_similar_column_names(table: Table, column_name: str, expected: list[str]) -> None:
assert table._get_similar_columns(column_name) == expected
Expand Down

0 comments on commit ac8ccb0

Please sign in to comment.