Skip to content

Commit b0225c0

Browse files
committed
Improve Python 3.11 compatibility
1 parent 5ea2466 commit b0225c0

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14059,12 +14059,9 @@ def save_teardown_screenshot(self):
1405914059
or self.save_screenshot_after_test
1406014060
or sys.version_info >= (3, 11)
1406114061
):
14062-
test_logpath = os.path.join(self.log_path, self.__get_test_id())
14063-
self.__create_log_path_as_needed(test_logpath)
1406414062
self.__set_last_page_screenshot()
1406514063
self.__set_last_page_url()
1406614064
self.__set_last_page_source()
14067-
sb_config._has_logs = True
1406814065
if self.__has_exception() or self.save_screenshot_after_test:
1406914066
if self.is_pytest:
1407014067
self.__add_pytest_html_extra()

seleniumbase/plugins/pytest_plugin.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,9 +1802,22 @@ def pytest_sessionfinish(session):
18021802
def pytest_terminal_summary(terminalreporter):
18031803
if "--co" in sys_argv or "--collect-only" in sys_argv:
18041804
return
1805-
if not sb_config.item_count > 0:
1805+
if (
1806+
not hasattr(terminalreporter, "stats")
1807+
or not hasattr(terminalreporter.stats, "keys")
1808+
):
1809+
return
1810+
if len(terminalreporter.stats.keys()) == 0:
1811+
return
1812+
if not sb_config._multithreaded and not sb_config._sbase_detected:
18061813
return
18071814
latest_logs_dir = os.path.join(os.getcwd(), "latest_logs") + os.sep
1815+
if (
1816+
"failed" in terminalreporter.stats.keys()
1817+
and os.path.exists(latest_logs_dir)
1818+
and os.listdir(latest_logs_dir)
1819+
):
1820+
sb_config._has_exception = True
18081821
if sb_config._multithreaded:
18091822
if os.path.exists(latest_logs_dir) and os.listdir(latest_logs_dir):
18101823
sb_config._has_exception = True
@@ -1814,7 +1827,7 @@ def pytest_terminal_summary(terminalreporter):
18141827
dash_lock_path = os.path.join(abs_path, dash_lock)
18151828
if os.path.exists(dash_lock_path):
18161829
sb_config._only_unittest = False
1817-
if (sb_config._has_exception or sb_config._multithreaded) and (
1830+
if sb_config._has_exception and (
18181831
sb_config.dashboard and not sb_config._only_unittest
18191832
):
18201833
# Print link a second time because the first one may be off-screen
@@ -2114,6 +2127,7 @@ def pytest_runtest_makereport(item, call):
21142127
):
21152128
# Handle a bug on Python 3.11 where exceptions aren't seen
21162129
log_path = ""
2130+
sb_config._has_logs = True
21172131
if hasattr(sb_config, "_test_logpath"):
21182132
log_path = sb_config._test_logpath
21192133
if sb_config.dashboard:

0 commit comments

Comments
 (0)