Skip to content

Commit b9f4a51

Browse files
committed
Use self._print() to print output in multithreaded mode
1 parent f03c595 commit b9f4a51

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6913,16 +6913,17 @@ def block_ads(self):
69136913
self.ad_block()
69146914

69156915
def _print(self, msg):
6916-
"""Same as Python's print(), but won't print during multithreaded runs
6917-
because overlapping print() commands may lead to unexpected output.
6918-
In most cases, the print() command won't print for multithreaded tests,
6919-
but there are some exceptions, and this will take care of those.
6920-
Here's an example of running tests multithreaded: "pytest -n=4".
6916+
"""Same as Python's print(), but also prints during multithreaded runs.
6917+
Normally, Python's print() command won't print for multithreaded tests.
6918+
Here's an example of running tests using multithreading: "pytest -n=4".
6919+
Here's how to print directly from sys without using a print() command:
69216920
To force a print during multithreaded tests, use: "sys.stderr.write()".
69226921
To print without the new-line character end, use: "sys.stdout.write()".
69236922
"""
69246923
if not sb_config._multithreaded:
69256924
print(msg)
6925+
else:
6926+
sys.stderr.write(msg)
69266927

69276928
def start_tour(self, name=None, interval=0):
69286929
self.play_tour(name=name, interval=interval)

0 commit comments

Comments
 (0)