Skip to content

Commit 2a4ccb4

Browse files
committed
fix tests
1 parent 60930e5 commit 2a4ccb4

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

test/plugins/test_lastgenre.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def _setup_config(
4747
self.plugin.setup()
4848
if not isinstance(whitelist, (bool, (str,))):
4949
# Explicit list of genres.
50-
self.plugin.processor.whitelist = whitelist
50+
self.plugin.whitelist = whitelist
5151

5252
def test_default(self):
5353
"""Fetch genres with whitelist and c14n deactivated"""
@@ -685,10 +685,10 @@ def test_blacklist_patterns(blacklist_dict, artist, genre, expected_forbidden):
685685
re.compile(pattern) for pattern in patterns
686686
]
687687

688-
plugin.processor.blacklist = compiled_blacklist
688+
plugin.blacklist = compiled_blacklist
689689

690-
# Test the is_forbidden method on processor
691-
result = plugin.processor.is_forbidden(genre, artist)
690+
# Test the _is_blacklisted method on the plugin
691+
result = plugin._is_blacklisted(genre, artist)
692692
assert result == expected_forbidden
693693

694694

@@ -727,11 +727,14 @@ def test_blacklist_file_format(file_content, expected_blacklist):
727727
blacklist_file = f.name
728728

729729
try:
730-
# We don't need a plugin instance, it's a static method
731-
mock_log = Mock()
732-
blacklist_result = lastgenre.DataFileLoader._load_blacklist(
733-
mock_log, blacklist_file
734-
)
730+
# Reset config before creating the plugin so setup() doesn't try to
731+
# open a stale file left over from a previous parametrized test run.
732+
import beets
733+
734+
beets.config["lastgenre"]["blacklist"] = False
735+
plugin = lastgenre.LastGenrePlugin()
736+
plugin.config["blacklist"] = blacklist_file
737+
blacklist_result = plugin._load_blacklist()
735738

736739
# Convert compiled regex patterns back to strings for comparison
737740
string_blacklist = {}
@@ -767,11 +770,16 @@ def test_blacklist_file_format_errors(invalid_content, expected_error_message):
767770
blacklist_file = f.name
768771

769772
try:
770-
# We don't need a plugin instance, it's a static method
771-
mock_log = Mock()
773+
# Reset config before creating the plugin so setup() doesn't try to
774+
# open a stale file left over from a previous parametrized test run.
775+
import beets
776+
777+
beets.config["lastgenre"]["blacklist"] = False
778+
plugin = lastgenre.LastGenrePlugin()
779+
plugin.config["blacklist"] = blacklist_file
772780

773781
with pytest.raises(UserError) as exc_info:
774-
lastgenre.DataFileLoader._load_blacklist(mock_log, blacklist_file)
782+
plugin._load_blacklist()
775783

776784
assert expected_error_message in str(exc_info.value)
777785

0 commit comments

Comments
 (0)