Skip to content

Commit a673ca2

Browse files
committed
Make sure we gather the driver log without breaking existing functionality
1 parent 0d0ac03 commit a673ca2

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

pytest_selenium/pytest_selenium.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,13 @@ def pytest_runtest_makereport(item, call):
183183
failure = (report.skipped and xfail) or (report.failed and not xfail)
184184
when = item.config.getini('selenium_capture_debug').lower()
185185
capture_debug = when == 'always' or (when == 'failure' and failure)
186-
if driver is not None:
187-
if capture_debug:
188-
exclude = item.config.getini('selenium_exclude_debug').lower()
186+
if capture_debug:
187+
exclude = item.config.getini('selenium_exclude_debug').lower()
188+
if 'logs' not in exclude:
189+
# gather logs that do not depend on a driver instance
190+
_gather_driver_log(item, summary, extra)
191+
if driver is not None:
192+
# gather debug that depends on a driver instance
189193
if 'url' not in exclude:
190194
_gather_url(item, report, driver, summary, extra)
191195
if 'screenshot' not in exclude:
@@ -194,12 +198,13 @@ def pytest_runtest_makereport(item, call):
194198
_gather_html(item, report, driver, summary, extra)
195199
if 'logs' not in exclude:
196200
_gather_logs(item, report, driver, summary, extra)
201+
# gather debug from hook implementations
197202
item.config.hook.pytest_selenium_capture_debug(
198203
item=item, report=report, extra=extra)
204+
if driver is not None:
205+
# allow hook implementations to further modify the report
199206
item.config.hook.pytest_selenium_runtest_makereport(
200207
item=item, report=report, summary=summary, extra=extra)
201-
# always gather driver logs
202-
_gather_driver_logs(item, summary, extra)
203208
if summary:
204209
report.sections.append(('pytest-selenium', '\n'.join(summary)))
205210
report.extra = extra
@@ -262,7 +267,7 @@ def _gather_logs(item, report, driver, summary, extra):
262267
format_log(log), '%s Log' % name.title()))
263268

264269

265-
def _gather_driver_logs(item, summary, extra):
270+
def _gather_driver_log(item, summary, extra):
266271
pytest_html = item.config.pluginmanager.getplugin('html')
267272
if hasattr(item.config, '_driver_log') and \
268273
os.path.exists(item.config._driver_log):

0 commit comments

Comments
 (0)