Skip to content

Commit 48b5529

Browse files
committed
Add updates for pytest
1 parent b17615d commit 48b5529

File tree

4 files changed

+30
-8
lines changed

4 files changed

+30
-8
lines changed

seleniumbase/core/log_helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ def log_test_failure_data(test, test_logpath, driver, browser, url=None):
192192
and test._outcome.errors
193193
):
194194
try:
195-
exc_message = test._outcome.errors[0][1][1]
196-
traceback_address = test._outcome.errors[0][1][2]
195+
exc_message = test._outcome.errors[-1][1][1]
196+
traceback_address = test._outcome.errors[-1][1][2]
197197
traceback_list = traceback.format_list(
198198
traceback.extract_tb(traceback_address)[1:]
199199
)

seleniumbase/core/report_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def process_failures(test, test_count, duration):
111111
and test._outcome.errors
112112
):
113113
try:
114-
exc_message = test._outcome.errors[0][1][1]
114+
exc_message = test._outcome.errors[-1][1][1]
115115
except Exception:
116116
exc_message = "(Unknown Exception)"
117117
else:

seleniumbase/fixtures/base_case.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15945,7 +15945,7 @@ def __get_exception_info(self):
1594515945
and self._outcome.errors
1594615946
):
1594715947
try:
15948-
exc_message = self._outcome.errors[0][1][1]
15948+
exc_message = self._outcome.errors[-1][1][1]
1594915949
except Exception:
1595015950
exc_message = "(Unknown Exception)"
1595115951
else:
@@ -16093,8 +16093,16 @@ def __has_exception(self):
1609316093
else:
1609416094
return False
1609516095
elif hasattr(self, "_outcome") and hasattr(self._outcome, "errors"):
16096-
if self._outcome.errors:
16097-
has_exception = True
16096+
if python3_11_or_newer:
16097+
if (
16098+
self._outcome.errors
16099+
and self._outcome.errors[-1]
16100+
and self._outcome.errors[-1][1]
16101+
):
16102+
has_exception = True
16103+
else:
16104+
if self._outcome.errors:
16105+
has_exception = True
1609816106
else:
1609916107
has_exception = sys.exc_info()[1] is not None
1610016108
if self.__will_be_skipped and hasattr(self, "_using_sb_fixture"):

seleniumbase/masterqa/master_qa.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
from seleniumbase.fixtures import js_utils
1212

1313

14+
python3_11_or_newer = False
15+
if sys.version_info >= (3, 11):
16+
python3_11_or_newer = True
17+
18+
1419
class MasterQA(BaseCase):
1520
def setUp(self):
1621
self.check_count = 0
@@ -309,8 +314,17 @@ def __has_exception(self):
309314
if hasattr(sys, "last_traceback") and sys.last_traceback is not None:
310315
has_exception = True
311316
elif hasattr(self, "_outcome"):
312-
if hasattr(self._outcome, "errors") and self._outcome.errors:
313-
has_exception = True
317+
if hasattr(self._outcome, "errors"):
318+
if python3_11_or_newer:
319+
if (
320+
self._outcome.errors
321+
and self._outcome.errors[-1]
322+
and self._outcome.errors[-1][1]
323+
):
324+
has_exception = True
325+
else:
326+
if self._outcome.errors:
327+
has_exception = True
314328
else:
315329
has_exception = sys.exc_info()[1] is not None
316330
return has_exception

0 commit comments

Comments
 (0)