This runs after item collection is finalized. https://docs.pytest.org/en/stable/reference.html
(session)
| 2146 | |
| 2147 | |
| 2148 | def pytest_collection_finish(session): |
| 2149 | """This runs after item collection is finalized. |
| 2150 | https://docs.pytest.org/en/stable/reference.html """ |
| 2151 | sb_config._context_of_runner = False # Context Manager Compatibility |
| 2152 | if "--co" in sys_argv or "--collect-only" in sys_argv: |
| 2153 | return |
| 2154 | if len(session.items) > 0 and not sb_config._multithreaded: |
| 2155 | from seleniumbase.core import download_helper |
| 2156 | from seleniumbase.core import proxy_helper |
| 2157 | |
| 2158 | log_helper.log_folder_setup( |
| 2159 | constants.Logs.LATEST + "/", sb_config.archive_logs |
| 2160 | ) |
| 2161 | download_helper.reset_downloads_folder() |
| 2162 | proxy_helper.remove_proxy_zip_if_present() |
| 2163 | if sb_config.dashboard and len(session.items) > 0: |
| 2164 | _create_dashboard_assets_() |
| 2165 | # Print the Dashboard path if at least one test runs. |
| 2166 | sb_config.item_count_untested = sb_config.item_count |
| 2167 | dash_path = os.path.join(os.getcwd(), "dashboard.html") |
| 2168 | dash_url = "file://" + dash_path.replace("\\", "/") |
| 2169 | star_len = len("Dashboard: ") + len(dash_url) |
| 2170 | with suppress(Exception): |
| 2171 | terminal_size = os.get_terminal_size().columns |
| 2172 | if terminal_size > 30 and star_len > terminal_size: |
| 2173 | star_len = terminal_size |
| 2174 | stars = "*" * star_len |
| 2175 | c1 = "" |
| 2176 | cr = "" |
| 2177 | if "linux" not in sys.platform: |
| 2178 | c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX |
| 2179 | cr = colorama.Style.RESET_ALL |
| 2180 | if sb_config._multithreaded: |
| 2181 | if ( |
| 2182 | hasattr(session.config, "workerinput") |
| 2183 | and session.config.workerinput["workerid"] == "gw0" |
| 2184 | ): |
| 2185 | sys.stderr.write( |
| 2186 | "\nDashboard: %s%s%s\n%s\n" % (c1, dash_url, cr, stars) |
| 2187 | ) |
| 2188 | else: |
| 2189 | print("Dashboard: %s%s%s\n%s" % (c1, dash_url, cr, stars)) |
| 2190 | htmlpath = session.config.getoption("--html", default=None) |
| 2191 | if htmlpath: |
| 2192 | with suppress(Exception): |
| 2193 | if getattr(sb_config, "_multithreaded", None): |
| 2194 | from filelock import FileLock |
| 2195 | dash_lock = FileLock(constants.Report.LOCKFILE) |
| 2196 | with dash_lock: |
| 2197 | _fix_html_report(htmlpath) |
| 2198 | else: |
| 2199 | _fix_html_report(htmlpath) |
| 2200 | |
| 2201 | |
| 2202 | def pytest_runtest_setup(item): |
nothing calls this directly
no test coverage detected
searching dependent graphs…