Python supprime la sortie d'impression de la fonction
with nostdout():
foo()
Busy Boar
with nostdout():
foo()
import contextlib
import io
import sys
@contextlib.contextmanager
def nostdout():
save_stdout = sys.stdout
sys.stdout = io.BytesIO()
yield
sys.stdout = save_stdout