From d17646461c2fac118c8167eae5075cb7e3fa71a8 Mon Sep 17 00:00:00 2001 From: Ardavan Alaei Fard Date: Thu, 7 Dec 2023 00:30:35 -0500 Subject: [PATCH] Added edge case code for solving issue 10825 --- src/_pytest/reports.py | 6 ++++++ testing/test_setup.py | 15 +++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 testing/test_setup.py diff --git a/src/_pytest/reports.py b/src/_pytest/reports.py index 74e8794b2..aa72bec56 100644 --- a/src/_pytest/reports.py +++ b/src/_pytest/reports.py @@ -340,6 +340,12 @@ class TestReport(BaseReport): str, TerminalRepr, ] = None + elif call.excinfo and when in ("setup", "teardown"): + outcome = "passed" + longrepr = excinfo + TerminalWriter().write( + msg=f"", Yellow=True + ) else: if not isinstance(excinfo, ExceptionInfo): outcome = "failed" diff --git a/testing/test_setup.py b/testing/test_setup.py new file mode 100644 index 000000000..83446727f --- /dev/null +++ b/testing/test_setup.py @@ -0,0 +1,15 @@ +def foo(): + """ + >>> foo() + 'bar' + """ + return "bar" + + +def setup(): + # """ + # >>> setup() + # 'ban' + # """ + # return "ban" + raise RuntimeError("Setup called!!! Oh No")