fix: correct package test import and mocks#55
Open
AlwinXue wants to merge 1 commit intoOSIPI:mainfrom
Open
Conversation
Made-with: Cursor
e486373 to
d0deef7
Compare
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.
Hi mentors! 👋
This PR addresses the test and control-flow issues reported in Issue #15.
The Problem:
The package test file imported
get_bids_metadatausing a broken relative import, which prevented the tests from running against the real module. In addition, the tests mockedget_sequence()as if it could returnNone, but the actual factory raisesValueErrorfor unsupported modalities or unmatched sequence classes. That made the tests assert an impossible execution path and left a deadif sequence is Nonebranch inget_bids_metadata().The Solution:
Correct Import: Updated the package test to import
get_bids_metadatafrompyaslreport.main.Realistic Error Mocks: Replaced impossible
return_value=Nonemocks withValueErrorside effects that match the real behavior ofget_sequence().Dead Branch Removal: Removed the unreachable
if sequence is Nonecheck fromget_bids_metadata().Stronger Assertions: Updated the tests to assert the actual error messages for unsupported modality and no matching sequence cases.
Validation:
Ran
python -m pytest package/src/pyaslreport/tests/test_package.py -qand all 4 tests passed.Fixes #15