Skip to content

motor: remove speed 0, degrees 0, etc checks - #553

Merged
dwalton76 merged 2 commits into
ev3dev:ev3dev-stretchfrom
dwalton76:motorzero
Nov 7, 2018
Merged

dwalton76 merged 2 commits into
ev3dev:ev3dev-stretchfrom
dwalton76:motorzero

Conversation

@dwalton76

Copy link
Copy Markdown
Collaborator

For issue #544

@dwalton76

Copy link
Copy Markdown
Collaborator Author

These two tests failed

======================================================================
ERROR: test_motor_on_for_degrees (__main__.TestAPI)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/api_tests.py", line 182, in test_motor_on_for_degrees
    m.on_for_degrees(None, 100)
  File "tests/../ev3dev2/motor.py", line 909 in on_for_degrees
    speed_sp = self._speed_native_units(speed)
  File "tests/../ev3dev2/motor.py", line 864, in _speed_native_units
    assert -100 <= speed <= 100,\
TypeError: unorderable types: int() <= NoneType()
======================================================================
ERROR: test_motor_on_for_rotations (__main__.TestAPI)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/api_tests.py", line 201, in test_motor_on_for_rotations
    m.on_for_rotations(None, 5)
  File "tests/../ev3dev2/motor.py", line 893, in on_for_rotations
    speed_sp = self._speed_native_units(speed)
  File "tests/../ev3dev2/motor.py", line 864, in _speed_native_units
    assert -100 <= speed <= 100,\
TypeError: unorderable types: int() <= NoneType()

Do we officially support accepting None for speed, rotations, degrees, or seconds? I did not test these when I was running through all the permutations.

@WasabiFan

Copy link
Copy Markdown
Member

I don't see a reason to support it. That being said, it certainly is nice when code tells you "None isn't a valid parameter value" when you make a mistake rather than "unorderable types: int() <= NoneType()" 😆

@dwalton76

Copy link
Copy Markdown
Collaborator Author

I don't see a reason to support it. That being said, it certainly is nice when code tells you "None isn't a valid parameter value" when you make a mistake rather than "unorderable types: int() <= NoneType()" 😆

We do not check/test for other unsupported types though (strings for instance)...any objections to just chopping these two test cases?

@WasabiFan

Copy link
Copy Markdown
Member

I think it's fine to remove them.

@dwalton76
dwalton76 merged commit 3a5054e into ev3dev:ev3dev-stretch Nov 7, 2018
@dwalton76
dwalton76 deleted the motorzero branch November 7, 2018 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants