beets/test/plugins
Arne Beer 4d7b9cb14b fix(lastgenre): Canonicalize keep_existing fallback
Fixes a bug where existing tags were set to None, if they weren't whitelisted, but an whitelisted canonicalized parent existed up the tree.

In all other cases, the original genres are canonicalized and considered for the final genre, except in the keep_existing logic branch.
This PR fixes the issue and results in the expected behavior for this combination of options.

For the bug to trigger several conditions had to be met:

- Canonicalization is enabled and a whitelist is specified.
- `force` and `keep_existing` are set. Meaning, that Lastfm is queried for a genre, but the existing genres are still left around when none are found online.
- A release with a non-whitelisted genre exists, but that genre has a whitelisted genre parent up the tree.
- That very release has no genre on lastfm.

This is rather convoluted, but stay with me :D
What would happen is the following:

- `keep_genres` is set to the existing genres, as `force` and `keep_existing` is set.
- Genres for `track`/`album`/`artist` aren't found for this release, as they don't exist in lastfm.
- Then the `keep_existing` logic is entered.
  - The old logic only checks if the existing genres have an **exact** match for the whitelist. In contrast to all other code branches, we don't do the `_try_resolve_stage` in case there's no direct match, resulting in no match.
- We continue to the fallback logic, which returns the fallback (`None` in my case)

This patch results in one last try to resolve the existing genres when `keep_existing` is set, which includes canonicalization (if enabled).
2026-01-31 13:22:56 +01:00
..
utils Nuked tests 2026-01-30 00:46:13 +00:00
__init__.py Correctly refactor tests 2023-10-17 19:39:03 +10:00
conftest.py Migrate mbcollection to use MusicBrainzAPI 2026-01-06 09:54:02 +00:00
lyrics_pages.py Address RUF012 2026-01-13 20:55:40 +00:00
test_acousticbrainz.py Reformat the codebase 2024-09-21 11:57:48 +01:00
test_advancedrewrite.py Update CI config, minimum ruff version, docs and add changelog note 2024-12-10 06:10:03 +00:00
test_albumtypes.py Configure future-annotations 2026-01-13 20:55:40 +00:00
test_art.py fetchart: Add support for configurable fallback cover art 2025-12-30 13:45:03 +01:00
test_aura.py Configure future-annotations 2026-01-13 20:55:40 +00:00
test_autobpm.py Skip autobpm tests if librosa isn't available 2024-11-30 09:32:08 -04:00
test_bareasc.py Reformat the codebase 2024-09-21 11:57:48 +01:00
test_beatport.py Use unittest.TestCase for tests that don't require the dir setup 2025-05-26 12:40:38 +01:00
test_bpd.py Address RUF012 2026-01-13 20:55:40 +00:00
test_bucket.py Future proof BucketPluginTest.test_year_single_year_last_folder 2024-12-27 16:28:38 -04:00
test_convert.py Configure future-annotations 2026-01-13 20:55:40 +00:00
test_discogs.py Remove utils, rework from_plugin method in ArtistState to from_config 2026-01-19 12:43:30 -08:00
test_edit.py Address RUF012 2026-01-13 20:55:40 +00:00
test_embedart.py Fix lint 2025-11-20 18:48:37 +01:00
test_embyupdate.py Fix formatting 2025-05-07 10:41:01 +01:00
test_export.py Reformat the codebase 2024-09-21 11:57:48 +01:00
test_fetchart.py Fix fetchart colors broken by 67e668d81f 2026-01-07 10:36:08 -08:00
test_filefilter.py Reformat the codebase 2024-09-21 11:57:48 +01:00
test_fromfilename.py Refactor tests using pytest 2025-09-30 15:54:33 +02:00
test_ftintitle.py Configure future-annotations 2026-01-13 20:55:40 +00:00
test_hook.py Address RUF012 2026-01-13 20:55:40 +00:00
test_ihate.py Replace assertFalse 2024-08-12 08:43:41 +01:00
test_importadded.py Replace string concatenation (' + ') 2025-08-30 23:10:15 +01:00
test_importfeeds.py pyupgrade Python 3.10 2025-11-08 12:09:52 +00:00
test_importsource.py importsource: Test skip, Test reimport-skip 2025-12-21 13:07:02 +01:00
test_info.py Replace assertEqual 2024-08-12 08:43:42 +01:00
test_inline.py Fixed unit tests import 2025-11-25 18:41:31 -05:00
test_ipfs.py Replace format calls with f-strings 2025-08-30 18:42:26 +01:00
test_keyfinder.py Replace assertEqual 2024-08-12 08:43:42 +01:00
test_lastgenre.py fix(lastgenre): Canonicalize keep_existing fallback 2026-01-31 13:22:56 +01:00
test_limit.py Replace string concatenation (' + ') 2025-08-30 23:10:15 +01:00
test_listenbrainz.py Migrate listenbrainz plugin to use our MusicBrainzAPI implementation 2026-01-06 00:27:36 +00:00
test_lyrics.py Enable RUF rules 2026-01-13 20:55:40 +00:00
test_mbcollection.py mbcollection: slight refactor 2026-01-06 09:54:02 +00:00
test_mbpseudo.py Configure future-annotations 2026-01-13 20:55:40 +00:00
test_mbsubmit.py Centralize AutotagStub test setup into AutotagImportTestCase 2025-05-17 03:31:58 +01:00
test_mbsync.py Fixed imports for all tests and added a bit of stricter type checking. 2025-07-15 15:03:14 +02:00
test_missing.py Migrate missing to use MusicBrainzAPI 2026-01-06 00:51:50 +00:00
test_mpdstats.py Address RUF012 2026-01-13 20:55:40 +00:00
test_musicbrainz.py Gracefully handle 404s when importing from MusicBrainz. 2026-01-22 12:20:04 +00:00
test_parentwork.py Migrate parentwork to use MusicBrainzAPI 2026-01-06 00:27:36 +00:00
test_permissions.py Replace assertPrem 2025-07-09 09:21:52 +01:00
test_play.py play plugin: $playlist marker for precise control where the playlist … (#4728) 2025-10-19 08:38:20 +02:00
test_playlist.py Replace string concatenation (' + ') 2025-08-30 23:10:15 +01:00
test_plexupdate.py Replace string concatenation (' + ') 2025-08-30 23:10:15 +01:00
test_plugin_mediafield.py Replace string concatenation (' + ') 2025-08-30 23:10:15 +01:00
test_random.py Readded licence. Removed last legacy occurrences of artist and 2026-01-30 00:30:21 +00:00
test_replace.py Feat: Add replace plugin (#5644) 2025-05-27 00:17:52 +02:00
test_replaygain.py Replace format calls with f-strings 2025-08-30 18:42:26 +01:00
test_scrub.py Move scrub test to a separate file 2025-05-17 03:32:00 +01:00
test_smartplaylist.py fix(smartplaylist): Resolve mypy type errors and update tests 2025-11-26 13:44:29 -05:00
test_spotify.py expand tests to include check for track artists 2025-12-18 16:23:58 -08:00
test_subsonicupdate.py Use unittest.TestCase for tests that don't require the dir setup 2025-05-26 12:40:38 +01:00
test_substitute.py Replace string concatenation (' + ') 2025-08-30 23:10:15 +01:00
test_the.py Use unittest.TestCase for tests that don't require the dir setup 2025-05-26 12:40:38 +01:00
test_thumbnails.py Remove no-op decargs 2025-07-08 11:37:33 +01:00
test_titlecase.py Cleanup, fix format 2025-12-16 19:06:37 -08:00
test_types_plugin.py refactor: convert _types from class attributes to cached properties 2025-07-16 14:45:25 +01:00
test_web.py plugins/web: fix endpoints /…/values/… 2025-11-15 21:02:38 +01:00
test_zero.py Add back tests as they were. 2025-10-14 03:17:34 +01:00