beets/test/plugins
Šarūnas Nejus 65e935bee5
Perform a regex substitution in the substitute plugin (#5357)
This utilises regex substitution in the substitute plugin. The previous
approach only used regex to match the pattern, then replaced it with a
static string. This change allows more complex substitutions, where the
output depends on the input.

### Example use case
Say we want to keep only the first artist of a multi-artist credit, as
in the following list:
```
Neil Young & Crazy Horse -> Neil Young
Michael Hurley, The Holy Modal Rounders, Jeffrey Frederick & The Clamtones -> Michael Hurley
James Yorkston and the Athletes -> James Yorkston
````
This would previously have required three separate rules, one for each
resulting artist. By using a regex substitution, we can get the desired
behaviour in a single rule:
```yaml
substitute:
  ^(.*?)(,| &| and).*: \1
```
(Capture the text until the first `,` ` &` or ` and`, then use that
capture group as the output)

### Notes
I've kept the previous behaviour of only applying the first matching
rule, but I'm not 100% sure it's the ideal approach.
I can imagine both cases where you want to apply several rules in
sequence and cases where you want to stop after the first match.
2024-11-22 05:02:50 +00:00
..
__init__.py Correctly refactor tests 2023-10-17 19:39:03 +10:00
lyrics_download_samples.py Fix lint issues 2024-09-21 11:59:18 +01:00
test_acousticbrainz.py Reformat the codebase 2024-09-21 11:57:48 +01:00
test_advancedrewrite.py Reformat the codebase 2024-09-21 11:57:48 +01:00
test_albumtypes.py Reformat the codebase 2024-09-21 11:57:48 +01:00
test_art.py Remove some lint exclusions and fix the issues 2024-09-21 11:59:19 +01:00
test_aura.py test helpers: remove redundant _get_item_count 2024-10-16 12:33:17 +01:00
test_autobpm.py autobpm: add tests 2024-08-19 22:44:17 +01:00
test_bareasc.py Reformat the codebase 2024-09-21 11:57:48 +01:00
test_beatport.py Use f-string syntax 2024-08-16 17:47:23 +01:00
test_bucket.py Reformat the codebase 2024-09-21 11:57:48 +01:00
test_convert.py Fix lints 2024-10-30 12:13:30 +00:00
test_discogs.py Fixes TypeError in the Discogs plugin (#5415) 2024-09-19 21:27:16 +01:00
test_edit.py Remove some lint exclusions and fix the issues 2024-09-21 11:59:19 +01:00
test_embedart.py Fix lint issues 2024-09-21 11:59:18 +01:00
test_embyupdate.py Replace assertEqual 2024-08-12 08:43:42 +01:00
test_export.py Reformat the codebase 2024-09-21 11:57:48 +01:00
test_fetchart.py Replace assertEqual 2024-08-12 08:43:42 +01:00
test_filefilter.py Reformat the codebase 2024-09-21 11:57:48 +01:00
test_ftintitle.py Remove redundant unit tests for ftintitle plugin 2024-10-01 15:55:38 -05:00
test_hook.py Replace assertIn 2024-08-12 08:43:42 +01:00
test_ihate.py Replace assertFalse 2024-08-12 08:43:41 +01:00
test_importadded.py Remove some lint exclusions and fix the issues 2024-09-21 11:59:19 +01:00
test_importfeeds.py Replace assertIn 2024-08-12 08:43:42 +01:00
test_info.py Replace assertEqual 2024-08-12 08:43:42 +01:00
test_ipfs.py Replace assertEqual 2024-08-12 08:43:42 +01:00
test_keyfinder.py Replace assertEqual 2024-08-12 08:43:42 +01:00
test_lastgenre.py Replace assertNotEqual 2024-08-12 08:43:42 +01:00
test_limit.py Reformat the codebase 2024-09-21 11:57:48 +01:00
test_lyrics.py Update Tekstowo backend to fetch lyrics directly 2024-10-12 02:14:18 +01:00
test_mbsubmit.py Replace assertIn 2024-08-12 08:43:42 +01:00
test_mbsync.py Remove redundant generate_album_info and generate_track_info functions 2024-10-16 06:39:30 +01:00
test_mpdstats.py Replace assertEqual 2024-08-12 08:43:42 +01:00
test_parentwork.py Introduce integration_test marker and update testing docs 2024-09-21 13:26:05 +01:00
test_permissions.py Remove some lint exclusions and fix the issues 2024-09-21 11:59:19 +01:00
test_play.py Reformat the codebase 2024-09-21 11:57:48 +01:00
test_player.py Remove some lint exclusions and fix the issues 2024-09-21 11:59:19 +01:00
test_playlist.py Replace assertEqual 2024-08-12 08:43:42 +01:00
test_plexupdate.py Replace assertEqual 2024-08-12 08:43:42 +01:00
test_plugin_mediafield.py Reformat the codebase 2024-09-21 11:57:48 +01:00
test_random.py Reformat the codebase 2024-09-21 11:57:48 +01:00
test_replaygain.py Replace assertAlmostEqual 2024-08-12 08:49:30 +01:00
test_smartplaylist.py Replace assertRaises 2024-08-12 08:43:42 +01:00
test_spotify.py Replace assertEqual 2024-08-12 08:43:42 +01:00
test_subsonicupdate.py Remove def suite TestLoader definitions 2024-07-28 18:58:51 +01:00
test_substitute.py Apply substitute rules in sequence 2024-10-16 16:36:36 +02:00
test_the.py Replace assertEqual 2024-08-12 08:43:42 +01:00
test_thumbnails.py Fix lint issues 2024-09-21 11:59:18 +01:00
test_types_plugin.py Replace assertRaises 2024-08-12 08:43:42 +01:00
test_web.py Replace assertCountEqual 2024-08-12 08:43:43 +01:00
test_zero.py Replace assertEqual 2024-08-12 08:43:42 +01:00