File tree 1 file changed +25
-10
lines changed 1 file changed +25
-10
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import time
4
4
import unittest
5
- from multiprocessing import Process
5
+ from multiprocessing import Process , Queue
6
+ from queue import Empty
6
7
7
8
from gpiozero import DigitalOutputDevice
8
9
@@ -24,23 +25,37 @@ def resethat():
24
25
time .sleep (0.5 )
25
26
26
27
27
- def reboot ():
28
- """Reboot hat"""
29
- from buildhat import Hat
30
- resethat ()
31
- h = Hat (debug = True )
32
- print (h .get ())
28
+ def reboot (exc ):
29
+ """Reboot hat and load firmware
30
+
31
+ :param exc: Queue to pass exceptions
32
+ """
33
+ try :
34
+ from buildhat import Hat
35
+ resethat ()
36
+ h = Hat (debug = True )
37
+ print (h .get ())
38
+ except Exception as e :
39
+ exc .put (e )
33
40
34
41
35
42
class TestFirmware (unittest .TestCase ):
36
43
"""Test firmware uploading functions"""
37
44
38
45
def test_upload (self ):
39
- """Test uploading firmware"""
40
- for _ in range (200 ):
41
- p = Process (target = reboot )
46
+ """Test upload firmware
47
+
48
+ :raises exc.get: Raised if exception in subprocess
49
+ """
50
+ for _ in range (500 ):
51
+ exc = Queue ()
52
+ p = Process (target = reboot , args = (exc ,))
42
53
p .start ()
43
54
p .join ()
55
+ try :
56
+ raise exc .get (False )
57
+ except Empty :
58
+ pass
44
59
45
60
46
61
if __name__ == '__main__' :
You can’t perform that action at this time.
0 commit comments