Same as Python's print(), but also prints during multithreaded runs. Normally, Python's print() command won't print for multithreaded tests. Here's an example of running tests using multithreading: "pytest -n=4". Here's how to print directly from sys without using a print() c
(self, msg)
| 10080 | raise NoSuchWindowException("Active window was already closed!") |
| 10081 | |
| 10082 | def _print(self, msg): |
| 10083 | """Same as Python's print(), but also prints during multithreaded runs. |
| 10084 | Normally, Python's print() command won't print for multithreaded tests. |
| 10085 | Here's an example of running tests using multithreading: "pytest -n=4". |
| 10086 | Here's how to print directly from sys without using a print() command: |
| 10087 | To force a print during multithreaded tests, use: "sys.stderr.write()". |
| 10088 | To print without the new-line character end, use: "sys.stdout.write()". |
| 10089 | """ |
| 10090 | if getattr(sb_config, "_multithreaded", None): |
| 10091 | if not isinstance(msg, str): |
| 10092 | with suppress(Exception): |
| 10093 | msg = str(msg) |
| 10094 | sys.stderr.write(msg + "\n") |
| 10095 | else: |
| 10096 | print(msg) |
| 10097 | |
| 10098 | ############ |
| 10099 |