@@ 148-166 (lines=19) @@ | ||
145 | assert self.m.speed == speed |
|
146 | kernel.run(main) |
|
147 | ||
148 | @given( speed = st.sampled_from([-50,0,100]), |
|
149 | port = st.integers(0,255), |
|
150 | cls = st.sampled_from([TrainMotor, DuploTrainMotor, WedoMotor, |
|
151 | ExternalMotor, InternalMotor]) |
|
152 | ) |
|
153 | def test_ramp_cancel_speed(self, cls, port, speed): |
|
154 | self._create_motor(cls) |
|
155 | self.m.port = port |
|
156 | ||
157 | async def child(): |
|
158 | await self.m.ramp_speed(speed, 2000) |
|
159 | await sleep(0.1) |
|
160 | await self.m.set_speed(speed+10) |
|
161 | ||
162 | async def main(): |
|
163 | t = await spawn(child()) |
|
164 | await t.join() |
|
165 | assert self.m.speed == speed+10 |
|
166 | kernel.run(main) |
|
167 | ||
168 | @given( pos = st.integers(-2147483648, 2147483647), |
|
169 | port = st.integers(0,255), |
|
@@ 130-146 (lines=17) @@ | ||
127 | args, kwargs = self.m.send_message.call_args |
|
128 | assert args[1] == self.write.get_bytes(port, 0, self.m._convert_speed_to_val(speed)) |
|
129 | ||
130 | @given( speed = st.integers(-100,100), |
|
131 | port = st.integers(0,255), |
|
132 | cls = st.sampled_from([TrainMotor, DuploTrainMotor, WedoMotor, |
|
133 | ExternalMotor, InternalMotor]) |
|
134 | ) |
|
135 | def test_ramp_speed(self, cls, port, speed): |
|
136 | self._create_motor(cls) |
|
137 | self.m.port = port |
|
138 | ||
139 | async def child(): |
|
140 | await self.m.ramp_speed(speed, 200) |
|
141 | await self.m.ramp_in_progress_task.join() |
|
142 | async def main(): |
|
143 | t = await spawn(child()) |
|
144 | await t.join() |
|
145 | assert self.m.speed == speed |
|
146 | kernel.run(main) |
|
147 | ||
148 | @given( speed = st.sampled_from([-50,0,100]), |
|
149 | port = st.integers(0,255), |