-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Catch ValueError when beetsplug.bpd cannot be imported #6170
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
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.
Pull Request Overview
This PR fixes a test collection error on macOS by correcting the exception type that pytest should catch when the beetsplug.bpd module cannot be imported. The issue occurs because the module raises ValueError instead of ImportError when dependencies are missing.
- Changed
pytest.importorskipto catchValueErrorinstead of the defaultImportError - Added changelog entry documenting the fix
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/plugins/test_bpd.py | Added exc_type=ValueError parameter to pytest.importorskip call to properly handle import failures |
| docs/changelog.rst | Added changelog entry describing the fix for the importskip case |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `docs/changelog.rst:69` </location>
<code_context>
- Refactored the ``beets/ui/commands.py`` monolithic file (2000+ lines) into
multiple modules within the ``beets/ui/commands`` directory for better
maintainability.
+- Correctly handle importskip case when Gst is not available.
2.5.1 (October 14, 2025)
</code_context>
<issue_to_address>
**suggestion (typo):** Possible typo: 'importskip' may need a space ('import skip case').
If 'importskip' is not a defined term in this project, consider changing it to 'import skip case' for better readability.
```suggestion
- Correctly handle import skip case when Gst is not available.
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
a10dfb9 to
6a2bcf7
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6170 +/- ##
==========================================
- Coverage 67.46% 67.46% -0.01%
==========================================
Files 136 136
Lines 18532 18535 +3
Branches 3130 3130
==========================================
+ Hits 12503 12504 +1
- Misses 5364 5366 +2
Partials 665 665
🚀 New features to boost your workflow:
|
6a2bcf7 to
93ce3de
Compare
pytest.importskip is used to catch the case when beetsplug.bpd cannot be imported. On macOS, the gi module was able to be imported, but when trying to specify `gi.require_version`, a ValueError is raised about Gst being unavailable. pytest does not catch this ValueError during importskip as it is not an ImportError, and thus the test suite errors during the test collection phase. With this change, we catch the ValueError, and re-raise it as an ImportError and pytest gracefully skips those tests.
93ce3de to
aa2dc90
Compare
Description
Catch ValueError when setting gst required version
pytest.importskipis used to catch the case when beetsplug.bpd cannot be imported. On macOS, thegimodule was able to be imported, but when trying to specifygi.require_version, aValueErroris raised about Gst being unavailable. pytest does not catch thisValueErrorduringimportskipas it is not anImportError, and thus the test suite errors during the test collection phase.With this change, we catch the ValueError, and re-raise it as an
ImportErrorand pytest gracefully skips those tests.Fixes #3324
To Do
I do not have a linux system to check to see if this change catches the appropriate failure mode there. This failure occurs strictly on macOS
docs/to describe it.)docs/changelog.rstto the bottom of one of the lists near the top of the document.)