Skip to content

Commit 9007c5a

Browse files
committed
Better compatibility with pytest plugins that force early exits
1 parent 66a96d3 commit 9007c5a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

seleniumbase/plugins/pytest_plugin.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ def pytest_terminal_summary(terminalreporter):
856856
def pytest_unconfigure():
857857
""" This runs after all tests have completed with pytest. """
858858
proxy_helper.remove_proxy_zip_if_present()
859-
if sb_config.reuse_session:
859+
if hasattr(sb_config, 'reuse_session') and sb_config.reuse_session:
860860
# Close the shared browser session
861861
if sb_config.shared_driver:
862862
try:
@@ -866,10 +866,13 @@ def pytest_unconfigure():
866866
except Exception:
867867
pass
868868
sb_config.shared_driver = None
869-
log_helper.archive_logs_if_set(sb_config.log_path, sb_config.archive_logs)
869+
if hasattr(sb_config, 'log_path'):
870+
log_helper.archive_logs_if_set(
871+
sb_config.log_path, sb_config.archive_logs)
870872

871873
# Dashboard post-processing: Disable time-based refresh and stamp complete
872-
if sb_config.dashboard and not sb_config._only_unittest:
874+
if hasattr(sb_config, 'dashboard') and (
875+
sb_config.dashboard and not sb_config._only_unittest):
873876
stamp = ""
874877
if sb_config._dash_is_html_report:
875878
# (If the Dashboard URL is the same as the HTML Report URL:)
@@ -985,7 +988,8 @@ def pytest_runtest_makereport(item, call):
985988
pytest_html = item.config.pluginmanager.getplugin('html')
986989
outcome = yield
987990
report = outcome.get_result()
988-
if pytest_html and report.when == 'call':
991+
if pytest_html and report.when == 'call' and (
992+
hasattr(sb_config, 'dashboard')):
989993
if sb_config.dashboard and not sb_config._sbase_detected:
990994
test_id, display_id = _get_test_ids_(item)
991995
r_outcome = report.outcome

0 commit comments

Comments
 (0)