Skip to content

Moved PytestPluginTestHelper class into test_helper.#6658

Open
semohr wants to merge 1 commit into
masterfrom
move_PytestPluginHelper
Open

Moved PytestPluginTestHelper class into test_helper.#6658
semohr wants to merge 1 commit into
masterfrom
move_PytestPluginHelper

Conversation

@semohr
Copy link
Copy Markdown
Contributor

@semohr semohr commented May 20, 2026

This PR moved the PytestPluginTestHelper which was duplicated in quite a few test files into the beets/test/helper.py file.

@semohr semohr requested a review from a team as a code owner May 20, 2026 21:00
Copilot AI review requested due to automatic review settings May 20, 2026 21:00
@github-actions
Copy link
Copy Markdown

Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.44%. Comparing base (611a19a) to head (c08a5e5).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6658   +/-   ##
=======================================
  Coverage   72.44%   72.44%           
=======================================
  Files         161      161           
  Lines       20710    20710           
  Branches     3276     3276           
=======================================
  Hits        15004    15004           
  Misses       4980     4980           
  Partials      726      726           
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
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

PR move pytest helper mixin out of duplicated test files into shared beets/test/helper.py, and also modernize some plugin tests to use that helper + requests-mock based HTTP/image mocking.

Changes:

  • Move PytestPluginTestHelper into beets/test/helper.py and switch plugin tests to import it.
  • Add pytest-focused helpers (PytestTestHelper, ImageRequestMocker) and switch FetchImageHelper from responses to requests-mock.
  • Refactor fetchart/embedart plugin tests to pytest fixtures + requests-mock style network mocking.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
beets/test/helper.py Add shared pytest helpers (PytestTestHelper, PytestPluginTestHelper) and new requests-mock based image mocking helper.
test/plugins/test_mbsync.py Remove local duplicated pytest helper class; import shared PytestPluginTestHelper.
test/plugins/test_hook.py Remove local duplicated pytest helper class; import shared PytestPluginTestHelper.
test/plugins/test_embedart.py Update embedart tests to use shared pytest helpers and image_request_mock fixture.
test/plugins/test_art.py Big refactor of fetchart tests to pytest fixtures + requests-mock, plus new request blocking behavior.
Comments suppressed due to low confidence (1)

test/plugins/test_art.py:56

  • grug see Settings subclass fetchart.FetchArtPlugin but custom __init__ not call FetchArtPlugin.__init__. that make object not real plugin (no config, no listener setup, no invariants). better keep this as plain settings holder (dataclass / SimpleNamespace) instead of inheriting plugin class, so future code not accidentally call plugin methods and explode.
class Settings(fetchart.FetchArtPlugin):
    """Used to pass settings to the ArtSources when the plugin isn't fully
    instantiated.
    """

    def __init__(self, **kwargs):
        for k, v in kwargs.items():
            setattr(self, k, v)

Comment thread test/plugins/test_art.py
Comment thread test/plugins/test_art.py
Comment thread beets/test/helper.py
@semohr semohr marked this pull request as draft May 20, 2026 21:37
@semohr semohr force-pushed the move_PytestPluginHelper branch from 0adb813 to 35ae121 Compare May 21, 2026 14:58
@semohr semohr force-pushed the move_PytestPluginHelper branch from 35ae121 to c08a5e5 Compare May 21, 2026 15:05
@semohr semohr marked this pull request as ready for review May 21, 2026 15:06
@github-actions
Copy link
Copy Markdown

Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.

Comment thread beets/test/helper.py

class PluginTestCase(PluginMixin, BeetsTestCase):
"""
DEPRECATED: Use pytest + PytestPluginTestHelper instead.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an fyi: We do not use deprecation warning here as this is very spammy when running tests.

Copy link
Copy Markdown
Member

@snejus snejus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that another PR that I've just merged defined a similar class in helper.py - you will want to remove it after rebase.

@semohr
Copy link
Copy Markdown
Contributor Author

semohr commented May 21, 2026

Hmm, which class do you mean?

@snejus
Copy link
Copy Markdown
Member

snejus commented May 21, 2026

Hmm, which class do you mean?

See line 420 in helper.py after rebase.

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.

3 participants