Commit 8c35b2a4 authored by Bryton Lacquement's avatar Bryton Lacquement 🚪 Committed by Julien Muchembled

shared: fix signature test under Python 3

parent d11daca2
...@@ -243,7 +243,7 @@ class Signature: ...@@ -243,7 +243,7 @@ class Signature:
def update(self, key, value): def update(self, key, value):
self.item_list.append(('%r: %r' % (key, value)).encode()) self.item_list.append(('%r: %r' % (key, value)).encode())
def hexdigest(self): def hexdigest(self): # -> str
m = md5() m = md5()
for item in self.item_list: for item in self.item_list:
m.update(item) m.update(item)
...@@ -253,8 +253,9 @@ class Signature: ...@@ -253,8 +253,9 @@ class Signature:
return b'\n'.join(self.item_list) return b'\n'.join(self.item_list)
def test(self, folder_path): def test(self, folder_path):
assert type(folder_path) is str, folder_path
digest = self.hexdigest() digest = self.hexdigest()
if os.path.basename(folder_path).encode('utf-8') == digest: if os.path.basename(folder_path) == digest:
target_path = os.path.join(folder_path, self.filename) target_path = os.path.join(folder_path, self.filename)
if os.path.exists(target_path) and open(target_path, 'rb').read() == self.dumps(): if os.path.exists(target_path) and open(target_path, 'rb').read() == self.dumps():
return True return True
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment