python unittest howto
Posted
by zubin71
on Stack Overflow
See other posts from Stack Overflow
or by zubin71
Published on 2010-04-16T19:41:20Z
Indexed on
2010/04/16
19:43 UTC
Read the original article
Hit count: 336
I`d like to know how I could unit-test the following module.
def download_distribution(url, tempdir):
""" Method which downloads the distribution from PyPI """
print "Attempting to download from %s" % (url,)
try:
url_handler = urllib2.urlopen(url)
distribution_contents = url_handler.read()
url_handler.close()
filename = get_file_name(url)
file_handler = open(os.path.join(tempdir, filename), "w")
file_handler.write(distribution_contents)
file_handler.close()
return True
except ValueError, IOError:
return False
© Stack Overflow or respective owner