Skip to content

Commit 01764b2

Browse files
committed
tests/pup/motors/measurements: Skip re-init.
We can't reinitialize a motor during a script, so we have to adapt this test. See: pybricks/support#561
1 parent c693cb6 commit 01764b2

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

tests/pup/motors/measurements.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from pybricks.tools import wait, StopWatch
1313

1414
# Initialize devices.
15-
motor = Motor(Port.A)
1615
motor = Motor(port=Port.A, positive_direction=Direction.CLOCKWISE, gears=[])
1716
ultrasonic_sensor = UltrasonicSensor(Port.C)
1817

@@ -43,8 +42,6 @@
4342
# Test absolute angle for sign change by putting it at +90 degrees clockwise.
4443
motor.run_target(500, 90)
4544
assert 85 <= motor.angle() <= 95, "Unable to put motor in +90 position."
46-
motor = Motor(Port.A, Direction.COUNTERCLOCKWISE)
47-
assert -85 >= motor.angle() >= -95, "Unexpected angle after CCW init."
4845

4946
# Test angle reset during hold.
5047
motor.reset_angle()
@@ -56,22 +53,6 @@
5653
assert motor.speed() < 10, "Motor moved during reset"
5754
wait(10)
5855

59-
# Test DC positive direction signs.
60-
for direction in (Direction.CLOCKWISE, Direction.COUNTERCLOCKWISE, "default"):
61-
62-
# Initialize the motor with given sign.
63-
if direction == "default":
64-
motor = Motor(Port.A)
65-
else:
66-
motor = Motor(Port.A, direction)
67-
68-
old_angle = motor.angle()
69-
motor.dc(100)
70-
wait(1000)
71-
assert motor.angle() > old_angle + 90
72-
motor.dc(0)
73-
wait(500)
74-
7556
# The motor is now in positive orientation. Test DC forward.
7657
old_angle = motor.angle()
7758
motor.dc(50)
@@ -111,4 +92,4 @@
11192

11293
# Compare with reported speed.
11394
for value in reported_speed:
114-
assert abs(value - real_speed) <= 100
95+
assert abs(value - real_speed) <= 150

0 commit comments

Comments
 (0)