def test_calc_sha1_by_file(self): import os, hashlib file_path = __file__ sha1 = Common.calc_sha1_by_file(file_path) with open(file_path, 'rb') as f: sha1_obj = hashlib.sha1() sha1_obj.update(f.read()) self.assertEqual(sha1, sha1_obj.hexdigest())