Skip to content

tests: replace function-scoped helper fixtures with TestHelper#6709

Open
snejus wants to merge 7 commits into
masterfrom
migrate-helper-test-classes
Open

tests: replace function-scoped helper fixtures with TestHelper#6709
snejus wants to merge 7 commits into
masterfrom
migrate-helper-test-classes

Conversation

@snejus

@snejus snejus commented Jun 4, 2026

Copy link
Copy Markdown
Member
  • Test setup was consolidated into shared helper classes instead of using local helper fixtures.
  • test/library/test_migrations.py now uses MigrationTestHelper to provide one common migration harness, with each test class defining only the legacy state and migration it needs.
  • Plugin tests in test/plugins/test_fuzzy.py, test/plugins/test_missing.py, and test/plugins/utils/test_playcount.py now rely on shared helpers like PluginTestHelper and TestHelper for common setup.

Note: I kept these fixtures in these files

  • test_query.py
  • plugins/test_random.py
  • plugins/test_aura.py
  • plugins/test_lyrics.py

because they intentionally use a higher scope, for example in test_query.py:

@pytest.fixture(scope="class")
def helper():
    helper = TestHelper()
    helper.setup_beets()

    yield helper

    helper.teardown_beets()

Using this setup pattern in test_query.py significantly improved testing durations.

Architecture impact

  • Test infrastructure now follows a clearer base-class pattern for shared setup.
  • Migration tests cleanly separate 'prepare old state' from 'run migration and verify result'.
  • Plugin tests now use the same setup path, which makes new tests easier to add and keeps test structure more consistent across files.

High-level outcome

  • Less duplicated fixture boilerplate.
  • More consistent and easier-to-read test architecture.
  • Tests stay focused on behavior being verified, which should make maintenance and future extension simpler.

Copilot AI review requested due to automatic review settings June 4, 2026 22:26
@snejus snejus requested a review from a team as a code owner June 4, 2026 22:26
@github-actions

github-actions Bot commented Jun 4, 2026

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

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.72%. Comparing base (7de08ba) to head (2ad2368).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6709      +/-   ##
==========================================
+ Coverage   74.51%   74.72%   +0.21%     
==========================================
  Files         162      162              
  Lines       20820    20820              
  Branches     3298     3298              
==========================================
+ Hits        15514    15558      +44     
+ Misses       4549     4505      -44     
  Partials      757      757              

see 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

grug see PR make test setup less copy-paste. instead of local helper fixtures per file, tests now inherit shared helper classes (TestHelper/PluginTestHelper) and migration tests get one common harness.

Changes:

  • swap function-scoped helper fixtures for TestHelper / PluginTestHelper base classes in plugin tests
  • add MigrationTestHelper harness so each migration test only defines legacy setup + migration under test
  • adjust playcount tests to use class-based helper + explicit log fixture injection

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
test/plugins/utils/test_playcount.py move from helper fixture to TestHelper inheritance; pass logger via fixture
test/plugins/test_missing.py use shared PluginTestHelper (plus IO mixin) for missing plugin CLI tests
test/plugins/test_fuzzy.py use PluginTestHelper for fuzzy plugin tests; remove local helper fixture
test/library/test_migrations.py introduce MigrationTestHelper and refactor migrations tests onto shared harness

Comment thread test/library/test_migrations.py
@snejus snejus force-pushed the migrate-helper-test-classes branch 2 times, most recently from f38bad8 to b6610ac Compare June 8, 2026 22:45
- Replace local setup fixtures with existing test helper base classes to reduce
  duplicated test setup.
@snejus snejus force-pushed the migrate-helper-test-classes branch from b6610ac to 8e7195c Compare June 11, 2026 16:05
snejus added 3 commits June 11, 2026 17:10
- Centralize migration test setup in a shared helper and update the migration
  tests to use the common pre-migration initialization flow.
- This removes repeated fixture boilerplate while keeping each test focused on
  the migration behavior it verifies.
- Replace duplicate pytest import helper fixtures with PluginMixin-based setup
  helpers.
- Keep plugin import tests aligned with shared beets setup behavior.
@snejus snejus force-pushed the migrate-helper-test-classes branch from 8e7195c to 9080832 Compare June 11, 2026 16:11
snejus added 3 commits June 11, 2026 20:42
- Dropped unused MusicBrainZ and Subsonic test helpers and imports.
- Keeps plugin test modules focused on the behavior they still exercise.
@snejus snejus force-pushed the migrate-helper-test-classes branch from 9080832 to 2ad2368 Compare June 11, 2026 19:43
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.

2 participants