Skip to content

Dashboard link missing at the start of pytest runs in multithreaded mode #1529

@mdmintz

Description

@mdmintz

Dashboard link missing at the start of pytest runs in multithreaded mode

Normally, when running tests with --dashboard set, you'll see the link to the dashboard at the start of the test run. Eg:

pytest --dashboard --html=report.html -v --headless --sjw --pls=none --rs
======================================= test session starts ========================================
platform darwin -- Python 3.10.5, pytest-7.1.3, pluggy-1.0.0 -- /Users/michael/.virtualenvs/sbase10/bin/python
metadata: {'Python': '3.10.5', 'Platform': 'macOS-10.14.6-x86_64-i386-64bit', 'Packages': {'pytest': '7.1.3', 'py': '1.11.0', 'pluggy': '1.0.0'}, 'Plugins': {'html': '2.0.1', 'xdist': '2.5.0', 'forked': '1.4.0', 'rerunfailures': '10.2', 'ordering': '0.6', 'cov': '3.0.0', 'metadata': '2.0.2', 'seleniumbase': '4.4.4'}}
rootdir: /Users/michael/github/SeleniumBase/examples, configfile: pytest.ini
plugins: html-2.0.1, xdist-2.5.0, forked-1.4.0, rerunfailures-10.2, ordering-0.6, cov-3.0.0, metadata-2.0.2, seleniumbase-4.4.4
collected 137 items                                                                                
Dashboard: /Users/michael/github/SeleniumBase/examples/dashboard.html
*********************************************************************
...

However, if running tests in multithreaded mode (-n 4, for example) then the Dashboard link is missing:

pytest -n 4 --dashboard --rs -v --headless --html=report.html --pls=none --sjw
======================================= test session starts ========================================
platform darwin -- Python 3.10.5, pytest-7.1.3, pluggy-1.0.0 -- /Users/michael/.virtualenvs/sbase10/bin/python
metadata: {'Python': '3.10.5', 'Platform': 'macOS-10.14.6-x86_64-i386-64bit', 'Packages': {'pytest': '7.1.3', 'py': '1.11.0', 'pluggy': '1.0.0'}, 'Plugins': {'html': '2.0.1', 'xdist': '2.5.0', 'forked': '1.4.0', 'rerunfailures': '10.2', 'ordering': '0.6', 'cov': '3.0.0', 'metadata': '2.0.2', 'seleniumbase': '4.3.8'}}
rootdir: /Users/michael/github/SeleniumBase/examples, configfile: pytest.ini
plugins: html-2.0.1, xdist-2.5.0, forked-1.4.0, rerunfailures-10.2, ordering-0.6, cov-3.0.0, metadata-2.0.2, seleniumbase-4.3.8
[gw0] darwin Python 3.10.5 cwd: /Users/michael/github/SeleniumBase/examples
[gw1] darwin Python 3.10.5 cwd: /Users/michael/github/SeleniumBase/examples
[gw2] darwin Python 3.10.5 cwd: /Users/michael/github/SeleniumBase/examples
[gw3] darwin Python 3.10.5 cwd: /Users/michael/github/SeleniumBase/examples
[gw0] Python 3.10.5 (v3.10.5:f377153967, Jun  6 2022, 12:36:10) [Clang 13.0.0 (clang-1300.0.29.30)]
[gw1] Python 3.10.5 (v3.10.5:f377153967, Jun  6 2022, 12:36:10) [Clang 13.0.0 (clang-1300.0.29.30)]
[gw2] Python 3.10.5 (v3.10.5:f377153967, Jun  6 2022, 12:36:10) [Clang 13.0.0 (clang-1300.0.29.30)]
[gw3] Python 3.10.5 (v3.10.5:f377153967, Jun  6 2022, 12:36:10) [Clang 13.0.0 (clang-1300.0.29.30)]
gw0 [137] / gw1 [137] / gw2 [137] / gw3 [137]
scheduling tests via LoadScheduling
...

And the reason this happens is because multithreaded mode captures the output of standard print statements by default.

The fix would involve swapping print() statements with sys.stderr.write(), which works in multithreaded mode.

Metadata

Metadata

Assignees

Labels

SeleniumBase 4SeleniumBase 4bugUh oh... Something needs to be fixed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions