10
10
class TestMotor (unittest .TestCase ):
11
11
"""Test motors"""
12
12
13
+ THRESHOLD_DISTANCE = 15
14
+
13
15
def test_rotations (self ):
14
16
"""Test motor rotating"""
15
17
m = Motor ('A' )
@@ -37,7 +39,7 @@ def test_nonblocking(self):
37
39
time .sleep (7 )
38
40
pos1 = m .get_aposition ()
39
41
diff = abs ((last - pos1 + 180 ) % 360 - 180 )
40
- self .assertLess (diff , 10 )
42
+ self .assertLess (diff , self . THRESHOLD_DISTANCE )
41
43
42
44
def test_nonblocking_multiple (self ):
43
45
"""Test motor nonblocking mode"""
@@ -62,23 +64,23 @@ def test_nonblocking_multiple(self):
62
64
time .sleep (7 )
63
65
pos1 = m1 .get_aposition ()
64
66
diff = abs ((last - pos1 + 180 ) % 360 - 180 )
65
- self .assertLess (diff , 10 )
67
+ self .assertLess (diff , self . THRESHOLD_DISTANCE )
66
68
pos2 = m2 .get_aposition ()
67
69
diff = abs ((last - pos2 + 180 ) % 360 - 180 )
68
- self .assertLess (diff , 10 )
70
+ self .assertLess (diff , self . THRESHOLD_DISTANCE )
69
71
70
72
def test_position (self ):
71
73
"""Test motor goes to desired position"""
72
74
m = Motor ('A' )
73
75
m .run_to_position (0 )
74
76
pos1 = m .get_aposition ()
75
77
diff = abs ((0 - pos1 + 180 ) % 360 - 180 )
76
- self .assertLess (diff , 10 )
78
+ self .assertLess (diff , self . THRESHOLD_DISTANCE )
77
79
78
80
m .run_to_position (180 )
79
81
pos1 = m .get_aposition ()
80
82
diff = abs ((180 - pos1 + 180 ) % 360 - 180 )
81
- self .assertLess (diff , 10 )
83
+ self .assertLess (diff , self . THRESHOLD_DISTANCE )
82
84
83
85
def test_time (self ):
84
86
"""Test motor runs for correct duration"""
0 commit comments