@@ -1013,20 +1013,20 @@ def test_aliases_config_format(
10131013 "invalid_config, expected_error" ,
10141014 [
10151015 # Plain string instead of mapping
1016- ("/path/to/aliases.txt" , "expected a mapping " ),
1016+ ("/path/to/aliases.txt" , "must be a dict " ),
10171017 # Integer
1018- (42 , "expected a mapping " ),
1018+ (42 , "must be a dict " ),
10191019 # Mapping with non-list value
1020- ({"hip hop" : "hip-hop" }, "expected a list of patterns " ),
1020+ ({"hip hop" : "hip-hop" }, "must be a list" ),
10211021 ],
10221022)
10231023def test_aliases_config_format_errors (config , invalid_config , expected_error ):
1024- """Test that invalid aliases config values raise UserError ."""
1024+ """Test that invalid aliases config values raise confuse.ConfigTypeError ."""
10251025 config ["lastgenre" ]["ignorelist" ] = (
10261026 False # prevent state leak from earlier tests
10271027 )
10281028 config ["lastgenre" ]["aliases" ] = invalid_config
1029- with pytest .raises (UserError ) as exc_info :
1029+ with pytest .raises (confuse . ConfigTypeError ) as exc_info :
10301030 lastgenre .LastGenrePlugin ()
10311031 assert expected_error in str (exc_info .value )
10321032
@@ -1067,9 +1067,9 @@ def test_aliases_normalize_before_ignorelist(config):
10671067 config ["lastgenre" ]["aliases" ] = {"hip hop" : ["hip-hop" ]}
10681068 plugin = lastgenre .LastGenrePlugin ()
10691069 plugin .setup ()
1070- plugin .ignorelist = lastgenre . LastGenrePlugin . _compile_ignorelist_patterns (
1071- { "*" : ["hip hop" ]}
1072- )
1070+ plugin .ignorelist = {
1071+ "*" : [re . compile ( "hip hop" , re . IGNORECASE )],
1072+ }
10731073
10741074 result = plugin ._resolve_genres (["hip-hop" ])
10751075 assert result == [], (
@@ -1147,9 +1147,10 @@ def test_client_normalization(config):
11471147 for template , patterns in aliases_config .items ()
11481148 for pat in patterns
11491149 ]
1150- ignorelist = lastgenre .LastGenrePlugin ._compile_ignorelist_patterns (
1151- ignorelist_config
1152- )
1150+ ignorelist = {
1151+ artist : [re .compile (pattern , re .IGNORECASE ) for pattern in patterns ]
1152+ for artist , patterns in ignorelist_config .items ()
1153+ }
11531154 client = lastgenre .client .LastFmClient (Mock (), 10 , ignorelist , aliases )
11541155
11551156 # 1. Test _tags_for directly: returns raw (un-normalized) tags from pylast
@@ -1215,4 +1216,4 @@ def test_default_aliases_logic(config, input_genre, expected_genre):
12151216 config ["lastgenre" ]["aliases" ] = True
12161217 plugin = lastgenre .LastGenrePlugin ()
12171218 result = normalize_genre (plugin ._log , plugin .aliases , input_genre )
1218- assert result == expected_genre
1219+ assert result == expected_genre
0 commit comments