fix(lastgenre): Reset plugin config in fixtured tests#6386
fix(lastgenre): Reset plugin config in fixtured tests#6386snejus merged 1 commit intobeetbox:masterfrom
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. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6386 +/- ##
=======================================
Coverage 69.33% 69.33%
=======================================
Files 141 141
Lines 18793 18793
Branches 3061 3061
=======================================
Hits 13031 13031
Misses 5117 5117
Partials 645 645 🚀 New features to boost your workflow:
|
9a8b2ac to
67544a4
Compare
|
The test failure seems to be a flaky one? |
3d0414c to
5d74d3e
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes a test isolation bug in the lastgenre plugin where global beets config state leaked between parametrized test fixtures. It extracts the plugin's default config dict into a @staticmethod method, and uses that method in the test harness to reset config state before each fixture run.
Changes:
- Extracted plugin default config dict into
LastGenrePlugin.default_configuration()static method and used it in__init__ - Added config reset before each
test_get_genreparametrized fixture by callingplugin.config.set(LastGenrePlugin.default_configuration()) - Added explicit
"count": 10to 3 test fixtures that previously relied on leaked state from earlier fixtures
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
beetsplug/lastgenre/__init__.py |
Extracts default config into a @staticmethod, uses it in __init__ |
test/plugins/test_lastgenre.py |
Resets plugin config to defaults before each parametrized test; adds explicit "count": 10 to 3 fixtures |
|
@snejus can you take a look here. I might have missed something when I first set up the pytest fixture based _get_genre tests. Would this be the right way to fix it or do you see another? |
5d74d3e to
18d4f96
Compare
|
Thanks for the hint @snejus I added a new |
18d4f96 to
a9a108d
Compare
|
You can redefine it in @pytest.fixture
def config(config):
return configI will be making some changes to how config is used by the tests so best to have this change at the module level for now! |
This would also slow down many of the tests as config initialisation is fairly time-consuming operation. |
a9a108d to
0763e64
Compare
That's a neat trick. Thanks. Adjusted my MR accordingly :) |
0763e64 to
7afe965
Compare
7afe965 to
723b4bb
Compare
I see you're also forced to use GitLab for work? 😁 |
Description
Fixes a bug in the lastgenre plugin, where test state bled into the following fixtures.
Each plugin has a view to the global persisted beets.config field. As a result, config variables that aren't explicitly overwritten are persisted in that global config view.
This commit exposes the lastgenre default config as a static method and uses that default config to reset the state in between fixture calls.
There were 3 tests that depended on
count: 10being set on previous test fixtures, which I adjusted accordingly.Discovered and discussed in #6317 , see #6317 (comment)