Avoir de fichier suivant handler.py
fonction Python simulation appelé subprocess
import job
def worker():
return job()
Et test suivant test_handler.py
import subprocess
def test_worker():
subprocess.Popen(['./handler.py'], stderr=subprocess.PIPE)
Comment puis-je moquer job
fonction, en tenant compte du fait que handler.py
est appelé à subprocess
Qu'en est-il de [mock] (https://docs.python.org/3/library/unittest.mock.html)? –
Question éditée, ceci est nécessaire dans le sous-processus – artie12
Certainement, la simulation pourrait vous aider! :-) –