feat: add context manager to suppress print from e.g. macros
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
import os
|
||||
from contextlib import contextmanager, redirect_stderr, redirect_stdout
|
||||
|
||||
|
||||
@contextmanager
|
||||
def suppress_output():
|
||||
"""Suppress both stdout and stderr by redirecting them to os.devnull."""
|
||||
with open(os.devnull, "w") as fnull:
|
||||
with redirect_stdout(fnull), redirect_stderr(fnull):
|
||||
yield
|
||||
Reference in New Issue
Block a user