コード例 #1
0
def test_motor_board_make_safe() -> None:
    """Test the make_safe method of the motor board."""
    mb = MotorBoard("SERIAL0", MockMotorBoardBackend())

    for m in mb.motors:
        m.power = 1

    mb.make_safe()

    for m in mb.motors:
        assert m.power == MotorSpecialState.BRAKE
コード例 #2
0
def test_motor_board_make_safe_option() -> None:
    """Test the default make_safe method of the motor board."""
    TEST_SAFE_STATES: List[MotorState] = [
        MotorSpecialState.BRAKE,
        MotorSpecialState.COAST,
        0,
        0.1,
    ]

    for safe_state in TEST_SAFE_STATES:

        mb = MotorBoard("SERIAL0", MockMotorBoardBackend(), safe_state=safe_state)

        for m in mb.motors:
            m.power = 1

        mb.make_safe()

        for m in mb.motors:
            assert m.power == safe_state