Skip to content

Commit 5b816bf

Browse files
committed
Update MasterQA error-handling
1 parent 10a0957 commit 5b816bf

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

seleniumbase/masterqa/master_qa.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
"""
2+
This tool allows testers to quickly verify pages while assisted by automation.
3+
"""
14
import os
25
import shutil
36
import sys
@@ -9,7 +12,9 @@
912
from seleniumbase.config import settings
1013
from seleniumbase.fixtures import js_utils
1114

12-
# This tool allows testers to quickly verify pages while assisted by automation
15+
python3 = True
16+
if sys.version_info[0] < 3:
17+
python3 = False
1318

1419

1520
class MasterQA(BaseCase):
@@ -63,7 +68,7 @@ def tearDown(self):
6368
"WARNING: %s manual checks were skipped! (MasterQA)"
6469
% self.check_count
6570
)
66-
if sys.exc_info()[1]:
71+
if self.__has_exception():
6772
self.__add_failure(sys.exc_info()[1])
6873
self.__process_manual_check_results(self.auto_close_results_page)
6974
super(MasterQA, self).tearDown()
@@ -304,6 +309,25 @@ def __wait_for_special_alert_absent(self):
304309
"%s seconds passed without human action! Stopping..." % timeout
305310
)
306311

312+
def __has_exception(self):
313+
has_exception = False
314+
if hasattr(sys, "last_traceback") and sys.last_traceback is not None:
315+
has_exception = True
316+
elif python3 and hasattr(self, "_outcome"):
317+
if hasattr(self._outcome, "errors") and self._outcome.errors:
318+
has_exception = True
319+
else:
320+
if python3:
321+
has_exception = sys.exc_info()[1] is not None
322+
else:
323+
if not hasattr(self, "_using_sb_fixture_class") and (
324+
not hasattr(self, "_using_sb_fixture_no_class")
325+
):
326+
has_exception = sys.exc_info()[1] is not None
327+
else:
328+
has_exception = len(str(sys.exc_info()[1]).strip()) > 0
329+
return has_exception
330+
307331
def __add_failure(self, exception=None):
308332
exc_info = None
309333
if exception:

0 commit comments

Comments
 (0)