Skip to content

Commit 68d4721

Browse files
MarvKlerMarvin Klerx
andauthored
throw continuable failure for count table keyword (#43)
* throw continuable failure for count table keyword * make continuable failure configurable with default value true --------- Co-authored-by: Marvin Klerx <marvinklerx20@gmail.com>
1 parent c2998bb commit 68d4721

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/Tables/keywords/getter.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from assertionengine import AssertionOperator, verify_assertion
77
from assertionengine.assertion_engine import EvaluationOperators, NumericalOperators
88
from robot.api.deco import keyword
9+
from robot.api.exceptions import ContinuableFailure
910

1011
from ..general.library_attributes import LibraryAttributes
1112
from ..utils.file_access import FileAccess
@@ -347,13 +348,14 @@ def get_table_row(
347348
return row_list
348349

349350
@keyword(tags=["Getter"])
350-
def count_table(
351+
def count_table( # noqa: PLR0913
351352
self,
352353
path: Path | str,
353354
axis: Axis,
354355
assertion_operator: AssertionOperator | None = None,
355356
assertion_expected: Any = None,
356357
message: str = "",
358+
continue_on_failure: bool = True,
357359
) -> int:
358360
"""
359361
Keyword for counting rows or columns in the provided table.
@@ -403,9 +405,17 @@ def count_table(
403405
or
404406
assertion_operator in EvaluationOperators
405407
):
406-
verify_assertion(axis_count, assertion_operator, assertion_expected, message)
408+
try:
409+
verify_assertion(axis_count, assertion_operator, assertion_expected, message)
410+
except AssertionError as e:
411+
err = message if message else str(e)
412+
if not continue_on_failure:
413+
raise AssertionError(err) # noqa: B904
414+
raise ContinuableFailure(err) # noqa: B904
415+
except Exception:
416+
raise
407417
else:
408418
raise ValueError(
409-
f"Unexpected operator for assertion: {assertion_operator}. Use only {list(NumericalOperators)}."
419+
f"Unexpected operator for assertion: {assertion_operator}. Use only {list(NumericalOperators)} or {list(EvaluationOperators)}."
410420
)
411421
return axis_count

0 commit comments

Comments
 (0)