-
-
Notifications
You must be signed in to change notification settings - Fork 263
Fixed an issue with equality checks on floating point values #2510
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
Conversation
Summary by CodeRabbitTests
WalkthroughThe pull request replaces floating-point assertion methods across multiple test files. Several tests switch from Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
LGTM 👍
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
backend/tests/apps/owasp/management/commands/owasp_create_project_metadata_file_test.py (1)
51-51: Follow pytest.approx convention for better readability.While the current usage works correctly, the idiomatic pytest pattern is to wrap the expected value rather than the actual value. This improves readability by making it clear which value is the reference.
Apply this diff to follow pytest conventions:
- assert pytest.approx(metadata["level"]) == 3.5 + assert metadata["level"] == pytest.approx(3.5)
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
backend/tests/apps/owasp/management/commands/owasp_create_project_metadata_file_test.py(1 hunks)backend/tests/apps/sitemap/views/base_test.py(2 hunks)backend/tests/apps/sitemap/views/chapter_test.py(2 hunks)backend/tests/apps/sitemap/views/committee_test.py(2 hunks)backend/tests/apps/sitemap/views/repository_test.py(2 hunks)backend/tests/apps/sitemap/views/static_test.py(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (5)
backend/tests/apps/sitemap/views/committee_test.py (1)
backend/apps/sitemap/views/base.py (1)
priority(50-52)
backend/tests/apps/sitemap/views/base_test.py (3)
backend/tests/apps/sitemap/views/static_test.py (1)
sitemap(11-12)backend/apps/sitemap/views/base.py (2)
get_static_priority(26-32)priority(50-52)backend/apps/sitemap/views/static.py (1)
priority(49-51)
backend/tests/apps/sitemap/views/chapter_test.py (2)
backend/apps/sitemap/views/base.py (1)
priority(50-52)backend/apps/sitemap/views/static.py (1)
priority(49-51)
backend/tests/apps/sitemap/views/repository_test.py (1)
backend/apps/sitemap/views/base.py (1)
priority(50-52)
backend/tests/apps/sitemap/views/static_test.py (1)
backend/apps/sitemap/views/static.py (1)
priority(49-51)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Run frontend e2e tests
- GitHub Check: Run backend tests
- GitHub Check: Run frontend unit tests
- GitHub Check: CodeQL (javascript-typescript)
🔇 Additional comments (5)
backend/tests/apps/sitemap/views/repository_test.py (1)
3-3: LGTM! Proper use of pytest.approx for floating point comparison.The changes correctly replace the direct floating point equality check with
pytest.approx(), which is the recommended pytest approach for comparing floating point values. This addresses SonarQube rule S1244 appropriately.Also applies to: 61-61
backend/tests/apps/sitemap/views/committee_test.py (1)
3-3: LGTM! Consistent floating point comparison fix.The changes properly use
pytest.approx()for the floating point comparison, maintaining consistency with the other sitemap test files and addressing the SonarQube rule S1244.Also applies to: 51-51
backend/tests/apps/sitemap/views/base_test.py (1)
24-25: LGTM! Comprehensive floating point comparison updates.All floating point comparisons in this test file have been properly updated to use
pytest.approx(), covering tests for both known and unknown paths as well as the priority method. The changes are consistent and correct.Also applies to: 28-28, 53-53
backend/tests/apps/sitemap/views/chapter_test.py (1)
3-3: LGTM! Proper floating point comparison implementation.The changes correctly implement
pytest.approx()for the floating point comparison, consistent with the pattern applied across all sitemap tests.Also applies to: 54-54
backend/tests/apps/sitemap/views/static_test.py (1)
61-61: LGTM! Proper floating point comparison in iterative test.The change correctly uses
pytest.approx()for comparing floating point priority values within the loop, ensuring accurate comparisons for all static routes.
|
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.
Actionable comments posted: 3
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
backend/tests/apps/github/api/internal/nodes/milestone_test.py(3 hunks)backend/tests/apps/github/api/internal/nodes/user_test.py(3 hunks)backend/tests/apps/owasp/api/internal/nodes/committee_test.py(2 hunks)backend/tests/apps/owasp/api/internal/nodes/common_test.py(2 hunks)backend/tests/apps/owasp/management/commands/owasp_create_project_metadata_file_test.py(1 hunks)backend/tests/apps/slack/admin/member_test.py(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- backend/tests/apps/owasp/management/commands/owasp_create_project_metadata_file_test.py
🚧 Files skipped from review as they are similar to previous changes (1)
- backend/tests/apps/owasp/api/internal/nodes/common_test.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Run frontend e2e tests
- GitHub Check: Run frontend unit tests
- GitHub Check: Run backend tests
- GitHub Check: CodeQL (javascript-typescript)
🔇 Additional comments (1)
backend/tests/apps/slack/admin/member_test.py (1)
33-33: Remove this review comment—the change is intentional and related to the PR scope.The modification removes
pytest.approx()from a string assertion, which is directly related to fixing SonarQube rule S1244 (floating-point equality checks). Thepytest.approx()function is for comparing floating-point numbers with tolerance, not for string comparisons, making its removal the correct fix. The leading space in" assigned user for {mock_member}."is pre-existing code and was not introduced by this change.Likely an incorrect or invalid review comment.



Fix SonarQube S1244: Use
math.isclose()instead of direct floating point equality in CommitteeNode timestamp test.Checklist
make check-testlocally; all checks and tests passed.