Skip to content

Commit

Permalink
more error handling in test.py
Browse files Browse the repository at this point in the history
  • Loading branch information
winsvega committed Dec 6, 2018
1 parent d458d0f commit 3b2fa1b
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3b2fa1b

Please sign in to comment.