Skip to content

Commit 609beda

Browse files
committed
Keep "self._print()" from printing during multithreaded runs
1 parent c7ca8da commit 609beda

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4865,8 +4865,16 @@ def block_ads(self):
48654865
self.ad_block()
48664866

48674867
def _print(self, msg):
4868-
""" Same as Python's print() """
4869-
print(msg)
4868+
"""Same as Python's print(), but won't print during multithreaded runs
4869+
because overlapping print() commands may lead to unexpected output.
4870+
In most cases, the print() command won't print for multithreaded tests,
4871+
but there are some exceptions, and this will take care of those.
4872+
Here's an example of running tests multithreaded: "pytest -n=4".
4873+
To force a print during multithreaded tests, use: "sys.stderr.write()".
4874+
To print without the new-line character end, use: "sys.stdout.write()".
4875+
"""
4876+
if not sb_config._multithreaded:
4877+
print(msg)
48704878

48714879
def start_tour(self, name=None, interval=0):
48724880
self.play_tour(name=name, interval=interval)

0 commit comments

Comments
 (0)