Moved PytestPluginTestHelper class into test_helper.#6658
Conversation
|
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. |
61b1cab to
0adb813
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 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:
|
There was a problem hiding this comment.
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
PytestPluginTestHelperintobeets/test/helper.pyand switch plugin tests to import it. - Add pytest-focused helpers (
PytestTestHelper,ImageRequestMocker) and switchFetchImageHelperfromresponsestorequests-mock. - Refactor
fetchart/embedartplugin 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
Settingssubclassfetchart.FetchArtPluginbut custom__init__not callFetchArtPlugin.__init__. that make object not real plugin (noconfig, 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)
0adb813 to
35ae121
Compare
35ae121 to
c08a5e5
Compare
|
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. |
|
|
||
| class PluginTestCase(PluginMixin, BeetsTestCase): | ||
| """ | ||
| DEPRECATED: Use pytest + PytestPluginTestHelper instead. |
There was a problem hiding this comment.
As an fyi: We do not use deprecation warning here as this is very spammy when running tests.
snejus
left a comment
There was a problem hiding this comment.
Note that another PR that I've just merged defined a similar class in helper.py - you will want to remove it after rebase.
|
Hmm, which class do you mean? |
See line 420 in |
This PR moved the
PytestPluginTestHelperwhich was duplicated in quite a few test files into thebeets/test/helper.pyfile.