-
Notifications
You must be signed in to change notification settings - Fork 228
Fix tests: Use hardcoded constants to fix TypeError #258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts SPI and UART test constants to use hardcoded 1MHz-derived PWM_FERQUENCY values instead of accessing hardware class attributes, preventing TypeErrors during test collection in environments where those attributes are not callable/constants. File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes - here's some feedback:
- In both
test_spi.pyandtest_uart.py, consider centralizing the1MHztest frequency into a shared constant (or helper) to avoid duplicating the magic number and to make future changes easier. - The hardcoded
PWM_FERQUENCYvalues use different numeric types (1000000.0vs1000000); if the tests don’t depend on float vs int semantics, it may be clearer to use the same type in both places for consistency.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In both `test_spi.py` and `test_uart.py`, consider centralizing the `1MHz` test frequency into a shared constant (or helper) to avoid duplicating the magic number and to make future changes easier.
- The hardcoded `PWM_FERQUENCY` values use different numeric types (`1000000.0` vs `1000000`); if the tests don’t depend on float vs int semantics, it may be clearer to use the same type in both places for consistency.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Fixes #257
Summary
The test suite was failing to collect tests on fresh installations because
test_spi.pyandtest_uart.pywere attempting to perform arithmetic on class properties (SPIMaster._frequencyandUART._baudrate) which are not callable constants in the test environment.Changes
tests/test_spi.pyto use a hardcoded 1MHz value forPWM_FERQUENCYinstead of accessing the class property.tests/test_uart.pyto use a hardcoded 1MHz value forPWM_FERQUENCY.Verification
python -m pytest tests/test_spi.py tests/test_uart.py --collect-onlylocally.Summary by Sourcery
Stabilize SPI and UART tests by decoupling them from runtime hardware configuration values.
Tests: