Skip to content

Commit

Permalink
Merge pull request #22 from netolyrg/fix_hook_error_issue_21
Browse files Browse the repository at this point in the history
fix issue #21
  • Loading branch information
HardNorth committed Apr 26, 2022
2 parents 475e8e2 + 9bf5f0f commit 1396d25
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
19 changes: 9 additions & 10 deletions behave_reportportal/behave_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ def _log_step_exception(self, step, item_id):
)
]
if step.exception:
not_empty_args = self.not_empty_exception_args(step.exception)
if not_empty_args:
message.append(", ".join(not_empty_args))
valuable_args = self.fetch_valuable_args(step.exception)
if valuable_args:
message.append(", ".join(valuable_args))
if step.error_message:
message.append(step.error_message)

Expand All @@ -281,9 +281,9 @@ def _log_step_exception(self, step, item_id):
def _log_scenario_exception(self, scenario):
message = ["Scenario '{}' finished with error.".format(scenario.name)]
if scenario.exception:
not_empty_args = self.not_empty_exception_args(scenario.exception)
if not_empty_args:
message.append(", ".join(not_empty_args))
valuable_args = self.fetch_valuable_args(scenario.exception)
if valuable_args:
message.append(", ".join(valuable_args))
if scenario.error_message:
message.append(scenario.error_message)

Expand Down Expand Up @@ -448,8 +448,7 @@ def convert_to_rp_status(behave_status):
return "PASSED"

@staticmethod
def not_empty_exception_args(exception):
def fetch_valuable_args(exception):
"""Return valuable exception args."""
if exception.args:
if any(exception.args):
return [a for a in exception.args if a]
if exception.args and any(exception.args):
return [str(arg) for arg in exception.args if arg]
5 changes: 3 additions & 2 deletions tests/units/test_rp_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,9 +824,10 @@ def test_log_cleanup_scenario_based(mock_timestamp, config, scope, item_id):
((None, None), None),
(("", None), None),
(("A", "", None), ["A"]),
(("A", ["A", "B", "C"]), ["A", "['A', 'B', 'C']"]),
],
)
def test_not_empty_exception_args(args, exp):
def test_fetch_valuable_args(args, exp):
exception = mock.Mock()
exception.args = args
assert BehaveAgent.not_empty_exception_args(exception) == exp
assert BehaveAgent.fetch_valuable_args(exception) == exp

0 comments on commit 1396d25

Please sign in to comment.