Skip to content

Conversation

LucienMorey
Copy link
Contributor

Went in to deal with on_enable not being called in test and found out that on_disable gets double called for teleop and auto mode.

@LucienMorey
Copy link
Contributor Author

Is it worth adding a unit test while I am here to check that these methods run in the modes indicated in the docs? It looks like I might be able to do something similar to the test_feedbacks_with_type_hints test in test_magicbot_feedback.py and call each mode manually? i figure I just need a counter for each thing and then I can assert the expected increases as I go through each mode

Copy link
Member

@virtuald virtuald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems good to me. A test would be nice, but if it's hard I won't require it.

I guess I'm surprised you decided to not call the execute() functions from test mode? But maybe that's just too much.

@auscompgeek
Copy link
Member

I'm surprised you decided to not call the execute() functions from test mode?

IMO test mode should be a "get out of your way and avoid doing too much magic" mode. If you think calling on_enable() in test mode makes sense, then that's fine by me too. Wasn't sure if there was any particular rhyme and reason initially for not doing so.

@auscompgeek
Copy link
Member

It's always struck me as odd that on_disable() is double-called when disabling the robot. We can follow up with some tests in another PR.

@auscompgeek auscompgeek merged commit 2c535d4 into robotpy:main May 3, 2025
18 checks passed
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.

3 participants