Renamed PluginTestCase to PluginUnitTestCase

This commit is contained in:
Sebastian Mohr 2025-09-17 19:18:48 +02:00
parent ad719d8668
commit 21d07b41ff
28 changed files with 70 additions and 68 deletions

View file

@ -676,7 +676,7 @@ def get_available_plugins():
]
class PluginTestCasePytest(PluginMixin, TestHelper):
class PluginTestCase(PluginMixin, TestHelper):
@pytest.fixture(autouse=True)
def _setup_teardown(self):
self.setup_beets()
@ -684,8 +684,8 @@ class PluginTestCasePytest(PluginMixin, TestHelper):
self.teardown_beets()
class PluginTestCase(PluginMixin, BeetsTestCase):
"""DEPRECATED: Use PluginTestCasePytest instead for new code!"""
class PluginUnitTestCase(PluginMixin, BeetsTestCase):
"""DEPRECATED: Use PluginTestCase instead for new code using pytest!"""
pass

View file

@ -16,13 +16,13 @@
import pytest
from beets.test.helper import PluginTestCase
from beets.test.helper import PluginUnitTestCase
from beets.ui import UserError
PLUGIN_NAME = "advancedrewrite"
class AdvancedRewritePluginTest(PluginTestCase):
class AdvancedRewritePluginTest(PluginUnitTestCase):
plugin = "advancedrewrite"
preload_plugin = False

View file

@ -16,12 +16,12 @@
from collections.abc import Sequence
from beets.test.helper import PluginTestCase
from beets.test.helper import PluginUnitTestCase
from beetsplug.albumtypes import AlbumTypesPlugin
from beetsplug.musicbrainz import VARIOUS_ARTISTS_ID
class AlbumTypesPluginTest(PluginTestCase):
class AlbumTypesPluginTest(PluginUnitTestCase):
"""Tests for albumtypes plugin."""
plugin = "albumtypes"

View file

@ -4,10 +4,10 @@
"""Tests for the 'bareasc' plugin."""
from beets import logging
from beets.test.helper import PluginTestCase, capture_stdout
from beets.test.helper import PluginUnitTestCase, capture_stdout
class BareascPluginTest(PluginTestCase):
class BareascPluginTest(PluginUnitTestCase):
"""Test bare ASCII query matching."""
plugin = "bareasc"

View file

@ -28,7 +28,7 @@ import confuse
import pytest
import yaml
from beets.test.helper import PluginTestCase
from beets.test.helper import PluginUnitTestCase
from beets.util import bluelet
bpd = pytest.importorskip("beetsplug.bpd")
@ -238,7 +238,7 @@ def start_server(args, assigned_port, listener_patch):
beets.ui.main(args)
class BPDTestHelper(PluginTestCase):
class BPDTestHelper(PluginUnitTestCase):
db_on_disk = True
plugin = "bpd"

View file

@ -29,7 +29,7 @@ from beets.test import _common
from beets.test.helper import (
AsIsImporterMixin,
ImportHelper,
PluginTestCase,
PluginUnitTestCase,
capture_log,
control_stdin,
)
@ -63,7 +63,7 @@ class ConvertMixin:
return path.read_bytes().endswith(tag.encode("utf-8"))
class ConvertTestCase(ConvertMixin, PluginTestCase):
class ConvertTestCase(ConvertMixin, PluginUnitTestCase):
db_on_disk = True
plugin = "convert"

View file

@ -1,10 +1,10 @@
import responses
from beets.test.helper import PluginTestCase
from beets.test.helper import PluginUnitTestCase
from beetsplug import embyupdate
class EmbyUpdateTest(PluginTestCase):
class EmbyUpdateTest(PluginUnitTestCase):
plugin = "embyupdate"
def setUp(self):

View file

@ -19,10 +19,10 @@ import re # used to test csv format
from xml.etree import ElementTree
from xml.etree.ElementTree import Element
from beets.test.helper import PluginTestCase
from beets.test.helper import PluginUnitTestCase
class ExportPluginTest(PluginTestCase):
class ExportPluginTest(PluginUnitTestCase):
plugin = "export"
def setUp(self):

View file

@ -18,10 +18,10 @@ import os
import sys
from beets import util
from beets.test.helper import PluginTestCase
from beets.test.helper import PluginUnitTestCase
class FetchartCliTest(PluginTestCase):
class FetchartCliTest(PluginUnitTestCase):
plugin = "fetchart"
def setUp(self):

View file

@ -16,11 +16,11 @@
import unittest
from beets.test.helper import PluginTestCase
from beets.test.helper import PluginUnitTestCase
from beetsplug import ftintitle
class FtInTitlePluginFunctional(PluginTestCase):
class FtInTitlePluginFunctional(PluginUnitTestCase):
plugin = "ftintitle"
def _ft_add_item(self, path, artist, title, aartist):

View file

@ -22,13 +22,13 @@ from contextlib import contextmanager
from typing import TYPE_CHECKING, Callable
from beets import plugins
from beets.test.helper import PluginTestCase, capture_log
from beets.test.helper import PluginUnitTestCase, capture_log
if TYPE_CHECKING:
from collections.abc import Iterator
class HookTestCase(PluginTestCase):
class HookTestCase(PluginUnitTestCase):
plugin = "hook"
preload_plugin = False

View file

@ -15,11 +15,11 @@
from mediafile import MediaFile
from beets.test.helper import PluginTestCase
from beets.test.helper import PluginUnitTestCase
from beets.util import displayable_path
class InfoTest(PluginTestCase):
class InfoTest(PluginUnitTestCase):
plugin = "info"
def test_path(self):

View file

@ -16,13 +16,13 @@ import os
from unittest.mock import Mock, patch
from beets.test import _common
from beets.test.helper import PluginTestCase
from beets.test.helper import PluginUnitTestCase
from beets.util import bytestring_path
from beetsplug.ipfs import IPFSPlugin
@patch("beets.util.command_output", Mock())
class IPFSPluginTest(PluginTestCase):
class IPFSPluginTest(PluginUnitTestCase):
plugin = "ipfs"
def test_stored_hashes(self):

View file

@ -13,10 +13,10 @@
"""Tests for the 'limit' plugin."""
from beets.test.helper import PluginTestCase
from beets.test.helper import PluginUnitTestCase
class LimitPluginTest(PluginTestCase):
class LimitPluginTest(PluginUnitTestCase):
"""Unit tests for LimitPlugin
Note: query prefix tests do not work correctly with `run_with_output`.

View file

@ -16,10 +16,10 @@ from unittest.mock import Mock, patch
from beets.autotag.hooks import AlbumInfo, TrackInfo
from beets.library import Item
from beets.test.helper import PluginTestCase, capture_log
from beets.test.helper import PluginUnitTestCase, capture_log
class MbsyncCliTest(PluginTestCase):
class MbsyncCliTest(PluginUnitTestCase):
plugin = "mbsync"
@patch(

View file

@ -17,11 +17,11 @@ from unittest.mock import ANY, Mock, call, patch
from beets import util
from beets.library import Item
from beets.test.helper import PluginTestCase
from beets.test.helper import PluginUnitTestCase
from beetsplug.mpdstats import MPDStats
class MPDStatsTest(PluginTestCase):
class MPDStatsTest(PluginUnitTestCase):
plugin = "mpdstats"
def test_update_rating(self):

View file

@ -19,7 +19,7 @@ from unittest.mock import patch
import pytest
from beets.library import Item
from beets.test.helper import PluginTestCase
from beets.test.helper import PluginUnitTestCase
from beetsplug import parentwork
work = {
@ -85,7 +85,7 @@ def mock_workid_response(mbid, includes):
@pytest.mark.integration_test
class ParentWorkIntegrationTest(PluginTestCase):
class ParentWorkIntegrationTest(PluginUnitTestCase):
plugin = "parentwork"
# test how it works with real musicbrainz data
@ -149,7 +149,7 @@ class ParentWorkIntegrationTest(PluginTestCase):
)
class ParentWorkTest(PluginTestCase):
class ParentWorkTest(PluginUnitTestCase):
plugin = "parentwork"
def setUp(self):

View file

@ -21,14 +21,18 @@ from unittest.mock import ANY, patch
import pytest
from beets.test.helper import CleanupModulesMixin, PluginTestCase, control_stdin
from beets.test.helper import (
CleanupModulesMixin,
PluginUnitTestCase,
control_stdin,
)
from beets.ui import UserError
from beets.util import open_anything
from beetsplug.play import PlayPlugin
@patch("beetsplug.play.util.interactive_open")
class PlayPluginTest(CleanupModulesMixin, PluginTestCase):
class PlayPluginTest(CleanupModulesMixin, PluginUnitTestCase):
modules = (PlayPlugin.__module__,)
plugin = "play"

View file

@ -18,10 +18,10 @@ from shlex import quote
import beets
from beets.test import _common
from beets.test.helper import PluginTestCase
from beets.test.helper import PluginUnitTestCase
class PlaylistTestCase(PluginTestCase):
class PlaylistTestCase(PluginUnitTestCase):
plugin = "playlist"
preload_plugin = False

View file

@ -1,10 +1,10 @@
import responses
from beets.test.helper import PluginTestCase
from beets.test.helper import PluginUnitTestCase
from beetsplug.plexupdate import get_music_section, update_plex
class PlexUpdateTest(PluginTestCase):
class PlexUpdateTest(PluginUnitTestCase):
plugin = "plexupdate"
def add_response_get_music_section(self, section_name="Music"):

View file

@ -25,7 +25,7 @@ from beets import config
from beets.dbcore import OrQuery
from beets.dbcore.query import FixedFieldSort, MultipleSort, NullSort
from beets.library import Album, Item, parse_query_string
from beets.test.helper import BeetsTestCase, PluginTestCase
from beets.test.helper import BeetsTestCase, PluginUnitTestCase
from beets.ui import UserError
from beets.util import CHAR_REPLACE, syspath
from beetsplug.smartplaylist import SmartPlaylistPlugin
@ -328,7 +328,7 @@ class SmartPlaylistTest(BeetsTestCase):
assert content == b"http://beets:8337/item/3/file\n"
class SmartPlaylistCLITest(PluginTestCase):
class SmartPlaylistCLITest(PluginUnitTestCase):
plugin = "smartplaylist"
def setUp(self):

View file

@ -7,7 +7,7 @@ import responses
from beets.library import Item
from beets.test import _common
from beets.test.helper import PluginTestCase
from beets.test.helper import PluginUnitTestCase
from beetsplug import spotify
@ -23,7 +23,7 @@ def _params(url):
return parse_qs(urlparse(url).query)
class SpotifyPluginTest(PluginTestCase):
class SpotifyPluginTest(PluginUnitTestCase):
plugin = "spotify"
@responses.activate

View file

@ -14,11 +14,11 @@
"""Test the substitute plugin regex functionality."""
from beets.test.helper import PluginTestCase
from beets.test.helper import PluginUnitTestCase
from beetsplug.substitute import Substitute
class SubstitutePluginTest(PluginTestCase):
class SubstitutePluginTest(PluginUnitTestCase):
plugin = "substitute"
preload_plugin = False

View file

@ -19,10 +19,10 @@ from datetime import datetime
import pytest
from confuse import ConfigValueError
from beets.test.helper import PluginTestCase
from beets.test.helper import PluginUnitTestCase
class TypesPluginTest(PluginTestCase):
class TypesPluginTest(PluginUnitTestCase):
plugin = "types"
def test_integer_modify_and_query(self):

View file

@ -3,12 +3,12 @@
from mediafile import MediaFile
from beets.library import Item
from beets.test.helper import PluginTestCase, control_stdin
from beets.test.helper import PluginUnitTestCase, control_stdin
from beets.util import syspath
from beetsplug.zero import ZeroPlugin
class ZeroPluginTest(PluginTestCase):
class ZeroPluginTest(PluginUnitTestCase):
plugin = "zero"
preload_plugin = False

View file

@ -20,7 +20,7 @@ from datetime import datetime
from beets.library import Item
from beets.test import _common
from beets.test.helper import PluginTestCase
from beets.test.helper import PluginUnitTestCase
def _parsetime(s):
@ -31,7 +31,7 @@ def _is_windows():
return platform.system() == "Windows"
class MetaSyncTest(PluginTestCase):
class MetaSyncTest(PluginUnitTestCase):
plugin = "metasync"
itunes_library_unix = os.path.join(_common.RSRC, b"itunes_library_unix.xml")
itunes_library_windows = os.path.join(

View file

@ -35,13 +35,12 @@ from beets.test.helper import (
ImportHelper,
PluginMixin,
PluginTestCase,
PluginTestCasePytest,
TerminalImportMixin,
)
from beets.util import syspath
class TestPluginRegistration(PluginTestCasePytest):
class TestPluginRegistration(PluginTestCase):
"""Ensure that we can dynamically add a plugin without creating
actual files on disk.
@ -103,7 +102,7 @@ class TestPluginRegistration(PluginTestCasePytest):
Album._types
class TestPluginListeners(PluginTestCasePytest, ImportHelper):
class TestPluginListeners(PluginTestCase, ImportHelper):
"""Test that plugin listeners are registered and called correctly."""
class DummyPlugin(plugins.BeetsPlugin):
@ -246,19 +245,18 @@ class TestPluginListenersParams(PluginMixin):
plugins.send("exit_cli", foo=5)
class PluginImportTestCase(ImportHelper, PluginTestCase):
class PromptChoicesTest(TerminalImportMixin, ImportHelper, PluginMixin):
@pytest.fixture(autouse=True)
def setup_teardown(self):
# Run old unitest setup/teardown methods
self.setUp()
yield
self.tearDown()
def setUp(self):
super().setUp()
self.prepare_album_for_import(2)
class PromptChoicesTest(TerminalImportMixin, PluginImportTestCase):
"""
FIXME: This test is quite messy and could use some cleanup.
"""
def setUp(self):
super().setUp()
self.setup_importer()
self.matcher = AutotagStub(AutotagStub.IDENT).install()
self.addCleanup(self.matcher.restore)

View file

@ -34,7 +34,7 @@ from beets.test import _common
from beets.test.helper import (
BeetsTestCase,
IOMixin,
PluginTestCase,
PluginUnitTestCase,
capture_stdout,
control_stdin,
has_program,
@ -812,7 +812,7 @@ class ImportTest(BeetsTestCase):
@_common.slow_test()
class TestPluginTestCase(PluginTestCase):
class TestPluginTestCase(PluginUnitTestCase):
plugin = "test"
def setUp(self):