diff --git a/test.py b/test.py index e0a3bc24cb..5a80d6d8bb 100755 --- a/test.py +++ b/test.py @@ -137,15 +137,19 @@ def validateTestFile(testFile): def hashFile(fname): with open(fname ,"rb") as f: - k = sha3.keccak_256() - if fname.endswith(".json"): - s = json.dumps(json.load(f), sort_keys=True, separators=(',', ':')) - elif fname.endswith(".yml"): - s = json.dumps(yaml.load(f), sort_keys=True, separators=(',', ':')) - else: - _die("Do not know how to hash:", fname) - k.update(s.encode('utf-8')) - return k.hexdigest() + try: + k = sha3.keccak_256() + if fname.endswith(".json"): + s = json.dumps(json.load(f), sort_keys=True, separators=(',', ':')) + elif fname.endswith(".yml"): + s = json.dumps(yaml.load(f), sort_keys=True, separators=(',', ':')) + else: + _die("Do not know how to hash:", fname) + k.update(s.encode('utf-8')) + return k.hexdigest() + except Exception as e: + _logerror("Error getting hash of the yml/json:", fname) + _logerror("Exception: ", str(e)) def checkFilled(jsonFile): jsonTest = readFile(jsonFile)