Skip to content

Commit fbbc687

Browse files
committed
Update console output location of the dashboard path
1 parent abc5914 commit fbbc687

File tree

1 file changed

+28
-25
lines changed

1 file changed

+28
-25
lines changed

seleniumbase/plugins/pytest_plugin.py

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -519,13 +519,12 @@ def pytest_addoption(parser):
519519

520520

521521
def pytest_configure(config):
522-
""" This runs after command line options have been parsed """
522+
""" This runs after command-line options have been parsed. """
523523
sb_config.item_count = 0
524524
sb_config.item_count_passed = 0
525525
sb_config.item_count_failed = 0
526526
sb_config.item_count_skipped = 0
527527
sb_config.item_count_untested = 0
528-
sb_config.item_count_finalized = False
529528
sb_config.is_pytest = True
530529
sb_config.browser = config.getoption('browser')
531530
sb_config.data = config.getoption('data')
@@ -668,35 +667,39 @@ def pytest_deselected(items):
668667
sb_config.item_count -= len(items)
669668

670669

671-
def pytest_runtest_setup():
672-
""" This runs before every test with pytest """
673-
if sb_config.dashboard:
674-
sb_config._sbase_detected = False
675-
if not sb_config.item_count_finalized:
676-
sb_config.item_count_finalized = True
677-
sb_config.item_count_untested = sb_config.item_count
678-
dashboard_html = os.getcwd() + "/dashboard.html"
679-
star_len = len("Dashboard: ") + len(dashboard_html)
680-
try:
681-
terminal_size = os.get_terminal_size().columns
682-
if terminal_size > 30 and star_len > terminal_size:
683-
star_len = terminal_size
684-
except Exception:
685-
pass
686-
stars = "*" * star_len
670+
def pytest_collection_finish(session):
671+
""" This runs after item collection is finalized.
672+
Print the dashboard path if at least one test runs.
673+
https://docs.pytest.org/en/stable/reference.html """
674+
if sb_config.dashboard and len(session.items) > 0:
675+
dash_path = os.getcwd() + "/dashboard.html"
676+
star_len = len("Dashboard: ") + len(dash_path)
677+
try:
678+
terminal_size = os.get_terminal_size().columns
679+
if terminal_size > 30 and star_len > terminal_size:
680+
star_len = terminal_size
681+
except Exception:
682+
pass
683+
stars = "*" * star_len
684+
c1 = ""
685+
cr = ""
686+
if "linux" not in sys.platform:
687687
colorama.init(autoreset=True)
688688
c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
689689
cr = colorama.Style.RESET_ALL
690-
if "linux" in sys.platform:
691-
c1 = ''
692-
cr = ''
693-
print("\nDashboard: %s%s%s\n%s" % (c1, dashboard_html, cr, stars))
690+
print("Dashboard: %s%s%s\n%s" % (c1, dash_path, cr, stars))
694691

695692

696-
def pytest_runtest_teardown(item):
697-
""" This runs after every test with pytest """
693+
def pytest_runtest_setup():
694+
""" This runs before every test with pytest. """
695+
if sb_config.dashboard:
696+
sb_config._sbase_detected = False
697+
698698

699-
# Make sure webdriver has exited properly and any headless display
699+
def pytest_runtest_teardown(item):
700+
""" This runs after every test with pytest.
701+
Make sure that webdriver and headless displays have exited.
702+
(Has zero effect on tests using --reuse-session / --rs) """
700703
try:
701704
self = item._testcase
702705
try:

0 commit comments

Comments
 (0)