diff --git a/beets/test/helper.py b/beets/test/helper.py index 0a0ed0892..6332c5217 100644 --- a/beets/test/helper.py +++ b/beets/test/helper.py @@ -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 diff --git a/test/plugins/test_advancedrewrite.py b/test/plugins/test_advancedrewrite.py index d2be1fa6c..c2727d20b 100644 --- a/test/plugins/test_advancedrewrite.py +++ b/test/plugins/test_advancedrewrite.py @@ -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 diff --git a/test/plugins/test_albumtypes.py b/test/plugins/test_albumtypes.py index 0a9d53349..38a686486 100644 --- a/test/plugins/test_albumtypes.py +++ b/test/plugins/test_albumtypes.py @@ -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" diff --git a/test/plugins/test_bareasc.py b/test/plugins/test_bareasc.py index e699a3dcf..aff6e3dfe 100644 --- a/test/plugins/test_bareasc.py +++ b/test/plugins/test_bareasc.py @@ -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" diff --git a/test/plugins/test_bpd.py b/test/plugins/test_bpd.py index 16e424d7e..7dbc96f9b 100644 --- a/test/plugins/test_bpd.py +++ b/test/plugins/test_bpd.py @@ -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" diff --git a/test/plugins/test_convert.py b/test/plugins/test_convert.py index 1452686a7..128b9a9a0 100644 --- a/test/plugins/test_convert.py +++ b/test/plugins/test_convert.py @@ -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" diff --git a/test/plugins/test_embyupdate.py b/test/plugins/test_embyupdate.py index 9c7104371..787059603 100644 --- a/test/plugins/test_embyupdate.py +++ b/test/plugins/test_embyupdate.py @@ -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): diff --git a/test/plugins/test_export.py b/test/plugins/test_export.py index f37a0d2a7..1a4cf3f19 100644 --- a/test/plugins/test_export.py +++ b/test/plugins/test_export.py @@ -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): diff --git a/test/plugins/test_fetchart.py b/test/plugins/test_fetchart.py index 853820d92..5a0304939 100644 --- a/test/plugins/test_fetchart.py +++ b/test/plugins/test_fetchart.py @@ -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): diff --git a/test/plugins/test_ftintitle.py b/test/plugins/test_ftintitle.py index 572431b45..ec6bc636b 100644 --- a/test/plugins/test_ftintitle.py +++ b/test/plugins/test_ftintitle.py @@ -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): diff --git a/test/plugins/test_hook.py b/test/plugins/test_hook.py index 3392d6881..0f9d59a86 100644 --- a/test/plugins/test_hook.py +++ b/test/plugins/test_hook.py @@ -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 diff --git a/test/plugins/test_info.py b/test/plugins/test_info.py index c1b3fc941..d0520224a 100644 --- a/test/plugins/test_info.py +++ b/test/plugins/test_info.py @@ -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): diff --git a/test/plugins/test_ipfs.py b/test/plugins/test_ipfs.py index b94bd551b..f28fa2a5e 100644 --- a/test/plugins/test_ipfs.py +++ b/test/plugins/test_ipfs.py @@ -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): diff --git a/test/plugins/test_limit.py b/test/plugins/test_limit.py index d77e47ca8..9fa12bec7 100644 --- a/test/plugins/test_limit.py +++ b/test/plugins/test_limit.py @@ -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`. diff --git a/test/plugins/test_mbsync.py b/test/plugins/test_mbsync.py index bb88e5e63..cf651622d 100644 --- a/test/plugins/test_mbsync.py +++ b/test/plugins/test_mbsync.py @@ -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( diff --git a/test/plugins/test_mpdstats.py b/test/plugins/test_mpdstats.py index 6f5d3f3ce..7e699a9b8 100644 --- a/test/plugins/test_mpdstats.py +++ b/test/plugins/test_mpdstats.py @@ -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): diff --git a/test/plugins/test_parentwork.py b/test/plugins/test_parentwork.py index 1abe25709..a378698d9 100644 --- a/test/plugins/test_parentwork.py +++ b/test/plugins/test_parentwork.py @@ -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): diff --git a/test/plugins/test_play.py b/test/plugins/test_play.py index 293a50a20..57f162b6e 100644 --- a/test/plugins/test_play.py +++ b/test/plugins/test_play.py @@ -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" diff --git a/test/plugins/test_playlist.py b/test/plugins/test_playlist.py index a8c145696..13431bce3 100644 --- a/test/plugins/test_playlist.py +++ b/test/plugins/test_playlist.py @@ -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 diff --git a/test/plugins/test_plexupdate.py b/test/plugins/test_plexupdate.py index ab53d8c2e..4cedb0480 100644 --- a/test/plugins/test_plexupdate.py +++ b/test/plugins/test_plexupdate.py @@ -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"): diff --git a/test/plugins/test_smartplaylist.py b/test/plugins/test_smartplaylist.py index d3569d836..7d4f3474e 100644 --- a/test/plugins/test_smartplaylist.py +++ b/test/plugins/test_smartplaylist.py @@ -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): diff --git a/test/plugins/test_spotify.py b/test/plugins/test_spotify.py index 86b5651b9..dc05567ae 100644 --- a/test/plugins/test_spotify.py +++ b/test/plugins/test_spotify.py @@ -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 diff --git a/test/plugins/test_substitute.py b/test/plugins/test_substitute.py index fc3789c0b..b5f9f1ab7 100644 --- a/test/plugins/test_substitute.py +++ b/test/plugins/test_substitute.py @@ -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 diff --git a/test/plugins/test_types_plugin.py b/test/plugins/test_types_plugin.py index 41807b80d..4e857292c 100644 --- a/test/plugins/test_types_plugin.py +++ b/test/plugins/test_types_plugin.py @@ -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): diff --git a/test/plugins/test_zero.py b/test/plugins/test_zero.py index 51913c8e0..44fbb5e1e 100644 --- a/test/plugins/test_zero.py +++ b/test/plugins/test_zero.py @@ -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 diff --git a/test/test_metasync.py b/test/test_metasync.py index 13c003a1c..2ff65877c 100644 --- a/test/test_metasync.py +++ b/test/test_metasync.py @@ -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( diff --git a/test/test_plugins.py b/test/test_plugins.py index 9395e9de3..72c1fcefd 100644 --- a/test/test_plugins.py +++ b/test/test_plugins.py @@ -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) diff --git a/test/test_ui.py b/test/test_ui.py index 534d0e466..abe95cba2 100644 --- a/test/test_ui.py +++ b/test/test_ui.py @@ -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):