@@ -999,20 +999,20 @@ def test_aliases_config_format(
999999 "invalid_config, expected_error" ,
10001000 [
10011001 # Plain string instead of mapping
1002- ("/path/to/aliases.txt" , "expected a mapping " ),
1002+ ("/path/to/aliases.txt" , "must be a dict " ),
10031003 # Integer
1004- (42 , "expected a mapping " ),
1004+ (42 , "must be a dict " ),
10051005 # Mapping with non-list value
1006- ({"hip hop" : "hip-hop" }, "expected a list of patterns " ),
1006+ ({"hip hop" : "hip-hop" }, "must be a list" ),
10071007 ],
10081008)
10091009def test_aliases_config_format_errors (config , invalid_config , expected_error ):
1010- """Test that invalid aliases config values raise UserError ."""
1010+ """Test that invalid aliases config values raise confuse.ConfigTypeError ."""
10111011 config ["lastgenre" ]["ignorelist" ] = (
10121012 False # prevent state leak from earlier tests
10131013 )
10141014 config ["lastgenre" ]["aliases" ] = invalid_config
1015- with pytest .raises (UserError ) as exc_info :
1015+ with pytest .raises (confuse . ConfigTypeError ) as exc_info :
10161016 lastgenre .LastGenrePlugin ()
10171017 assert expected_error in str (exc_info .value )
10181018
@@ -1053,9 +1053,9 @@ def test_aliases_normalize_before_ignorelist(config):
10531053 config ["lastgenre" ]["aliases" ] = {"hip hop" : ["hip-hop" ]}
10541054 plugin = lastgenre .LastGenrePlugin ()
10551055 plugin .setup ()
1056- plugin .ignorelist = lastgenre . LastGenrePlugin . _compile_ignorelist_patterns (
1057- { "*" : ["hip hop" ]}
1058- )
1056+ plugin .ignorelist = {
1057+ "*" : [re . compile ( "hip hop" , re . IGNORECASE )],
1058+ }
10591059
10601060 result = plugin ._resolve_genres (["hip-hop" ])
10611061 assert result == [], (
@@ -1133,9 +1133,10 @@ def test_client_normalization(config):
11331133 for template , patterns in aliases_config .items ()
11341134 for pat in patterns
11351135 ]
1136- ignorelist = lastgenre .LastGenrePlugin ._compile_ignorelist_patterns (
1137- ignorelist_config
1138- )
1136+ ignorelist = {
1137+ artist : [re .compile (pattern , re .IGNORECASE ) for pattern in patterns ]
1138+ for artist , patterns in ignorelist_config .items ()
1139+ }
11391140 client = lastgenre .client .LastFmClient (Mock (), 10 , ignorelist , aliases )
11401141
11411142 # 1. Test _tags_for directly: returns raw (un-normalized) tags from pylast
@@ -1201,4 +1202,4 @@ def test_default_aliases_logic(config, input_genre, expected_genre):
12011202 config ["lastgenre" ]["aliases" ] = True
12021203 plugin = lastgenre .LastGenrePlugin ()
12031204 result = normalize_genre (plugin ._log , plugin .aliases , input_genre )
1204- assert result == expected_genre
1205+ assert result == expected_genre
0 commit comments