- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
class TestCase(unittest2.TestCase):
def md5Checksum(self,filePath):
"""
Calculates MD5sum hash of a file.
It does this as a stream 1k blocks, for large files.
We checksum the sample LFD we download as a test, in order to check it gave us the right one back, no corruption.
Returns MD5sum as string.
"""
try:
with open(filePath, 'rb') as fh:
m = hashlib.md5()
while True:
data = fh.read(1024) #: Read 1kb chunks, for large files.
if not data:
break
else:
m.update(data)
return str(m.hexdigest())
except Exception as e:
self.fail(str( e ))
return ""