Skip to content

Commit 1cc27b2

Browse files
committedOct 26, 2021
test callback
1 parent 67c976f commit 1cc27b2

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
 

‎test/motors.py

+9
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,14 @@ def test_pwm(self):
5858
self.assertRaises(MotorException, m.pwm, -2)
5959
self.assertRaises(MotorException, m.pwm, 2)
6060

61+
def test_callback(self):
62+
m = Motor('A')
63+
def handle_motor(speed, pos, apos):
64+
handle_motor.evt += 1
65+
handle_motor.evt = 0
66+
m.when_rotated = handle_motor
67+
m.run_for_seconds(1)
68+
self.assertGreater(handle_motor.evt, 0)
69+
6170
if __name__ == '__main__':
6271
unittest.main()

0 commit comments

Comments
 (0)
Please sign in to comment.