Skip to content

Conversation

@j9ac9k
Copy link
Contributor

@j9ac9k j9ac9k commented Nov 18, 2025

Description

Catch ValueError when setting gst required version

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.

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

  • Documentation. (If you've added a new command-line flag, for example, find the appropriate page under docs/ to describe it.)
  • Changelog. (Add an entry to docs/changelog.rst to the bottom of one of the lists near the top of the document.)
  • Tests. (Very much encouraged but not strictly required.)

@j9ac9k j9ac9k requested a review from a team as a code owner November 18, 2025 20:16
Copilot AI review requested due to automatic review settings November 18, 2025 20:16
Copy link
Contributor

Copilot AI left a 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.importorskip to catch ValueError instead of the default ImportError
  • 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.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a 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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@j9ac9k j9ac9k force-pushed the handle-importskip-in-test_bpd branch from a10dfb9 to 6a2bcf7 Compare November 18, 2025 20:28
@codecov
Copy link

codecov bot commented Nov 19, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.46%. Comparing base (88ca0ce) to head (aa2dc90).
⚠️ Report is 2 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
beetsplug/bpd/gstplayer.py 50.00% 2 Missing ⚠️
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              
Files with missing lines Coverage Δ
beetsplug/bpd/gstplayer.py 21.15% <50.00%> (+0.23%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@semohr semohr self-assigned this Nov 19, 2025
@j9ac9k j9ac9k force-pushed the handle-importskip-in-test_bpd branch from 6a2bcf7 to 93ce3de Compare November 19, 2025 11:35
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.
@j9ac9k j9ac9k force-pushed the handle-importskip-in-test_bpd branch from 93ce3de to aa2dc90 Compare November 19, 2025 11:43
@semohr semohr enabled auto-merge November 19, 2025 11:48
@semohr semohr merged commit f79c125 into beetbox:master Nov 19, 2025
17 checks passed
@j9ac9k j9ac9k deleted the handle-importskip-in-test_bpd branch November 19, 2025 11:50
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.

bpd plugin not working

2 participants