Skip to content

Commit

Permalink
Fix using CalledProcessError instead of using pytest.fail
Browse files Browse the repository at this point in the history
  • Loading branch information
DriesSchaumont committed Jun 6, 2023
1 parent 92e0767 commit 42e2d2c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Changelog
*********

0.3.1 (6/06/2023)
================
* `run_component`: fix a bug where `pytest.fail` was used when running a component failed instead of using `CalledProcessError`.

0.3.0 (6/06/2023)
=================
* `run_component`: when the component fails, stack traces from helper functions are no longer shown.
Expand Down
9 changes: 5 additions & 4 deletions viashpy/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def run_component(caplog, executable, viash_source_config_path, viash_executable
def run_and_handle_errors(function_to_run):
@wraps(function_to_run)
def wrapper(*args, **kwargs):
__tracebackhide__ = True
try:
return function_to_run(*args, **kwargs)
except CalledProcessError as e:
Expand All @@ -109,10 +110,10 @@ def wrapper(*args, **kwargs):
logger.info(
f"Captured component output was:\n{e.stdout.decode('utf-8')}"
)
pytest.fail(
f"The component exited with exitcode {e.returncode}.",
pytrace=False,
)
# Create a new CalledProcessError object. This removes verbosity from the original object
raise CalledProcessError(
e.returncode, e.cmd, output=None, stderr=None
) from None

return wrapper

Expand Down

0 comments on commit 42e2d2c

Please sign in to comment.