So I have installed pymox and I would like to test this method:
class HttpStorage():
def download(self, input, output):
try:
file_to_download = urllib2.urlopen(input)
except URLError:
raise IOError("Opening input URL failed")
f = open(output, "wb")
f.write(file_to_download.read())
f.close()
return True
I am reading through the pymox documentation but I cannot figure out how to do it. Could you help me with some example code?
You could try this format to test your download funciton, as the urllib2.openurl() has been mocked to do unit test.