Skip to content

fix: correct package test import and mocks#55

Open
AlwinXue wants to merge 1 commit intoOSIPI:mainfrom
AlwinXue:alwin/fix-issue-15
Open

fix: correct package test import and mocks#55
AlwinXue wants to merge 1 commit intoOSIPI:mainfrom
AlwinXue:alwin/fix-issue-15

Conversation

@AlwinXue
Copy link
Copy Markdown

@AlwinXue AlwinXue commented Mar 31, 2026

Hi mentors! 👋

This PR addresses the test and control-flow issues reported in Issue #15.

The Problem:
The package test file imported get_bids_metadata using a broken relative import, which prevented the tests from running against the real module. In addition, the tests mocked get_sequence() as if it could return None, but the actual factory raises ValueError for unsupported modalities or unmatched sequence classes. That made the tests assert an impossible execution path and left a dead if sequence is None branch in get_bids_metadata().

The Solution:
Correct Import: Updated the package test to import get_bids_metadata from pyaslreport.main.
Realistic Error Mocks: Replaced impossible return_value=None mocks with ValueError side effects that match the real behavior of get_sequence().
Dead Branch Removal: Removed the unreachable if sequence is None check from get_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 -q and all 4 tests passed.

Fixes #15

@AlwinXue AlwinXue force-pushed the alwin/fix-issue-15 branch from e486373 to d0deef7 Compare March 31, 2026 01:47
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.

Remove dead if sequence is None check and fix impossible test mocks in test_package.py

1 participant