Background: I am trying to test my wrapper class for git. This class does things like retry git commands when they hang or fail (Our repos are huge). I can mock git with something like mockproc - https://pypi.python.org/pypi/MockProc/
The problem I am facing is how to test retry logic, Ideally what I want is the ability to do this -
@integrationtest('git')
def test_git_fetch(mock_proc):
mock_proc.add_scripts("sleep (60)",
"sleep (60)",
"exit (-1)" )
mygit.fetch()
assert mock_proc.output_signal_count == 3
assert mock_proc.get_output_signals[0] == -1
So in this case, when mygit.fetch()
retries git 3 times, each time it runs the scripts defined in add_scripts
function. With mockproc
module I can mock any command for a given script, but I am stumped about how to achieve the retry testing such that each retry runs a different script. I would be grateful if someone can point to some module which can help me achieving this or some way to extend mockproc to add retry handling.