mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 14:01:15 +02:00
Cancellable md5sum calculation on thread, Ref. gui#2239
This commit is contained in:
1 parent
6868e20a70
commit
dc377165f2
4 files changed
+47
-2
No files matched your search
@@ -17,6 +17,7 @@
|
||||
|
||||
import os
|
||||
import sys
|
||||
import threading
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
@@ -57,6 +58,18 @@ def test_md5sum(tmpdir):
|
||||
assert f.read() == '5d41402abc4b2a76b9719d911017c592'
|
||||
|
||||
|
||||
def test_md5sum_stopped_event(tmpdir):
|
||||
fake_img = str(tmpdir / 'hello_stopped')
|
||||
with open(fake_img, 'w+') as f:
|
||||
f.write('hello')
|
||||
|
||||
event = threading.Event()
|
||||
event.set()
|
||||
|
||||
assert md5sum(fake_img, stopped_event=event) is None
|
||||
assert not os.path.exists(str(tmpdir / 'hello_stopped.md5sum'))
|
||||
|
||||
|
||||
def test_md5sum_existing_digest(tmpdir):
|
||||
fake_img = str(tmpdir / 'hello')
|
||||
|
||||
|
||||
Reference in new issue
Block a user