TST: add branch coverage for fin_flutter_analysis and fix keyword argument bug#904
Merged
Gui-FernandesBR merged 3 commits intoRocketPy-Team:developfrom Dec 4, 2025
Conversation
This commit increases test coverage for utilities.py by adding three new tests that cover previously untested branches in the fin_flutter_analysis function. The tests cover the see_prints=True branch, see_graphs=True branch, and both flags enabled simultaneously. During testing, discovered and fixed a bug where the filename parameter was incorrectly passed as a positional argument to _flutter_plots, which requires it as a keyword-only argument. This would cause a TypeError at runtime when users attempted to save flutter plots to files. Changes: - Add test_fin_flutter_analysis_with_prints for print branch coverage - Add test_fin_flutter_analysis_with_graphs for plotting branch coverage - Add test_fin_flutter_analysis_complete_output for combined coverage - Fix filename argument bug in fin_flutter_analysis (line 286) - Fix test_flutter_plots to use keyword argument for filename - Increases utilities.py coverage from 68% to 69% (+2 statements)
Member
Gui-FernandesBR
left a comment
There was a problem hiding this comment.
@erielC congratulations on your first contribution! Code looks clean and good, I appreciate your effort on this, thank you!!
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #904 +/- ##
===========================================
+ Coverage 80.27% 81.01% +0.74%
===========================================
Files 104 107 +3
Lines 12769 13642 +873
===========================================
+ Hits 10250 11052 +802
- Misses 2519 2590 +71 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Gui-FernandesBR
approved these changes
Dec 4, 2025
Member
|
Great first PR! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request type
Checklist
black rocketpy/ tests/) has passed locallypytest tests -m slow --runslow) have passed locallyCurrent behavior
The
fin_flutter_analysisfunction inrocketpy/utilities.pyhad several untested code branches:see_prints=Truebranch was never executed in testssee_graphs=Truebranch was never executed in testsutilities.pywas at 68%Additionally, there was a latent bug where the
filenameparameter was passed as a positional argument to_flutter_plots(), but the function signature defines it as a keyword-only parameter (after*). This would causeTypeError: _flutter_plots() takes 3 positional arguments but 4 were givenwhen users attempted to save flutter plots to files.New behavior
Tests Added:
test_fin_flutter_analysis_with_prints- Tests thesee_prints=Truebranch, ensuring print statements execute correctly and the function returns the expected tupletest_fin_flutter_analysis_with_graphs- Tests thesee_graphs=Truebranch, ensuring plotting functionality works and returnsNone(uses@patchto mock matplotlib)test_fin_flutter_analysis_complete_output- Tests both flags enabled simultaneously for complete branch coverageBugs Fixed:
fin_flutter_analysis(line 286): Changed_flutter_plots(flight, flutter_mach, safety_factor, filename)to_flutter_plots(flight, flutter_mach, safety_factor, filename=filename)test_flutter_plotsto correctly passfilenameas a keyword argumentCoverage Impact:
utilities.pytest coverage from 68% to 69%Breaking change
Additional information
Context: This PR is part of my application for the RocketPy Library Development team (Option 2: Add new tests to improve coverage).
Testing Methodology:
flight_calisto_custom_windfixture@patch("matplotlib.pyplot.show")to mock matplotlib, preventing plot windows during test executionQuality Checks:
Before Tests:

After Tests:
