Skip to content

Commit 7d68e73

Browse files
committed
change flag name
1 parent 9190916 commit 7d68e73

3 files changed

Lines changed: 15 additions & 10 deletions

File tree

python/lib/sift_client/_tests/util/test_test_results_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ def test_bad_assert(self, report_context, step):
386386
"Has a bad assert and shows assertion errors. Pytest util should mark this as error.",
387387
) as nested_substep_2_context:
388388
nested_substep_2 = nested_substep_2_context.current_step
389-
nested_substep_2_context.show_assertion_errors = True
389+
nested_substep_2_context.assertion_as_fail_not_error = True
390390
nested_substep_2_context.force_result = True
391391
assert False == True
392392
with substep_context.substep(

python/lib/sift_client/util/test_results/context_manager.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,14 @@ def __exit__(self, exc_type, exc_value, traceback):
9595
return True
9696

9797
def new_step(
98-
self, name: str, description: str | None = None, show_assertion_errors: bool = True
98+
self, name: str, description: str | None = None, assertion_as_fail_not_error: bool = True
9999
) -> NewStep:
100100
"""Alias to return a new step context manager from this report context. Use create_step for actually creating a TestStep in the current context."""
101101
return NewStep(
102-
self, name=name, description=description, show_assertion_errors=show_assertion_errors
102+
self,
103+
name=name,
104+
description=description,
105+
assertion_as_fail_not_error=assertion_as_fail_not_error,
103106
)
104107

105108
def get_next_step_path(self) -> str:
@@ -195,28 +198,28 @@ class NewStep(AbstractContextManager):
195198

196199
report_context: ReportContext
197200
client: SiftClient
198-
show_assertion_errors: bool = True
201+
assertion_as_fail_not_error: bool = True
199202
current_step: TestStep | None = None
200203

201204
def __init__(
202205
self,
203206
report_context: ReportContext,
204207
name: str,
205208
description: str | None = None,
206-
show_assertion_errors: bool = True,
209+
assertion_as_fail_not_error: bool = True,
207210
):
208211
"""Initialize a new step context.
209212
210213
Args:
211214
report_context: The report context to create the step in.
212215
name: The name of the step.
213216
description: The description of the step.
214-
show_assertion_errors: Whether to show assertion errors in the step (exists because users don't want to see them when using pytest).
217+
assertion_as_fail_not_error: Mark steps with assertion errors as failed instead of error+traceback (some users want assertions to work as simple failures especially when using pytest).
215218
"""
216219
self.report_context = report_context
217220
self.client = report_context.report.client
218221
self.current_step = self.report_context.create_step(name, description)
219-
self.show_assertion_errors = show_assertion_errors
222+
self.assertion_as_fail_not_error = assertion_as_fail_not_error
220223

221224
def __enter__(self):
222225
"""Enter the context manager to create a new step.
@@ -243,7 +246,7 @@ def update_step_from_result(
243246
error_info = None
244247
assert self.current_step is not None
245248
if exc:
246-
if isinstance(exc_value, AssertionError) and not self.show_assertion_errors:
249+
if isinstance(exc_value, AssertionError) and not self.assertion_as_fail_not_error:
247250
# If we're not showing assertion errors (i.e. pytest), mark step as failed but don't set error info.
248251
self.report_context.record_step_outcome(False, self.current_step)
249252
else:
@@ -435,5 +438,7 @@ def report_outcome(self, name: str, result: bool, reason: str | None = None) ->
435438
def substep(self, name: str, description: str | None = None) -> NewStep:
436439
"""Alias to return a new step context manager from the current step. The ReportContext will manage nesting of steps."""
437440
return self.report_context.new_step(
438-
name=name, description=description, show_assertion_errors=self.show_assertion_errors
441+
name=name,
442+
description=description,
443+
assertion_as_fail_not_error=self.assertion_as_fail_not_error,
439444
)

python/lib/sift_client/util/test_results/pytest_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def _step_impl(
6464
name = str(request.node.name)
6565
existing_docstring = request.node.obj.__doc__ or None
6666
with report_context.new_step(
67-
name=name, description=existing_docstring, show_assertion_errors=False
67+
name=name, description=existing_docstring, assertion_as_fail_not_error=False
6868
) as new_step:
6969
yield new_step
7070
if hasattr(request.node, "rep_call") and request.node.rep_call.excinfo:

0 commit comments

Comments
 (0)