diff --git a/tutorial/tests/testsuite/helpers.py b/tutorial/tests/testsuite/helpers.py index b203a542..3b3b81d3 100644 --- a/tutorial/tests/testsuite/helpers.py +++ b/tutorial/tests/testsuite/helpers.py @@ -9,6 +9,7 @@ import ipywidgets import pytest +from _pytest.outcomes import Failed from IPython.display import Code from IPython.display import display as ipython_display from ipywidgets import HTML @@ -275,8 +276,15 @@ def to_html(self) -> str: status_text = "Failed" case TestOutcome.TEST_ERROR: status_class = "test-error" - icon = "🚨" - status_text = "Syntax Error" + if isinstance(self.exception, SyntaxError): + icon = "🚨" + status_text = "Syntax Error" + else: + icon = "⚠️" + exc_name = ( + type(self.exception).__name__ if self.exception else "Error" + ) + status_text = f"Runtime Error ({exc_name})" case _: status_class = "test-error" icon = "⚠️" @@ -768,6 +776,7 @@ def pytest_exception_interact( TestOutcome.FAIL if exc.errisinstance(AssertionError) or exc.errisinstance(pytest.fail.Exception) + or exc.errisinstance(Failed) else TestOutcome.TEST_ERROR ) self.tests[report.nodeid] = TestCaseResult( diff --git a/tutorial/tests/testsuite/testsuite.py b/tutorial/tests/testsuite/testsuite.py index 707643ad..79300d38 100644 --- a/tutorial/tests/testsuite/testsuite.py +++ b/tutorial/tests/testsuite/testsuite.py @@ -34,7 +34,6 @@ IPytestOutcome, IPytestResult, ResultCollector, - TestOutcome, TestResultOutput, ) @@ -66,20 +65,6 @@ def run_pytest_for_function( test_results=list(result_collector.tests.values()), ) case pytest.ExitCode.TESTS_FAILED: - if any( - test.outcome == TestOutcome.TEST_ERROR - for test in result_collector.tests.values() - ): - return IPytestResult( - function=function, - status=IPytestOutcome.PYTEST_ERROR, - exceptions=[ - test.exception - for test in result_collector.tests.values() - if test.exception - ], - ) - return IPytestResult( function=function, status=IPytestOutcome.FINISHED,