Replace unittest.TestCase, ImportHelper by ImportTestCase

This commit is contained in:
Šarūnas Nejus 2024-07-03 12:01:41 +01:00
parent 6c1e26acc9
commit 0b5b94460a
No known key found for this signature in database
GPG key ID: DD28F6704DBE3435
6 changed files with 28 additions and 27 deletions

View file

@ -535,7 +535,7 @@ class LibTestCase(BeetsTestCase):
super().tearDown()
class ImportHelper(TestHelper):
class ImportHelper:
"""Provides tools to setup a library, a directory containing files that are
to be imported and an import session. The class also provides stubs for the
autotagging library and several assertions for the library.
@ -644,6 +644,10 @@ class ImportHelper(TestHelper):
self.assertEqual(len(os.listdir(syspath(self.libdir))), 0)
class ImportTestCase(ImportHelper, BeetsTestCase):
pass
class ImportSessionFixture(importer.ImportSession):
"""ImportSession that can be controlled programaticaly.

View file

@ -22,7 +22,7 @@ from beets.test import _common
from beets.test.helper import (
AutotagStub,
BeetsTestCase,
ImportHelper,
ImportTestCase,
TerminalImportSessionSetup,
control_stdin,
)
@ -323,7 +323,7 @@ class EditCommandTest(BeetsTestCase, EditMixin):
@_common.slow_test()
class EditDuringImporterTest(
TerminalImportSessionSetup, BeetsTestCase, ImportHelper, EditMixin
TerminalImportSessionSetup, ImportTestCase, EditMixin
):
"""TODO"""

View file

@ -24,12 +24,12 @@ from mediafile import MediaFile
from beets import config
from beets.test import _common
from beets.test.helper import ImportHelper, capture_log
from beets.test.helper import ImportTestCase, capture_log
from beets.util import bytestring_path, displayable_path, syspath
from beetsplug.filefilter import FileFilterPlugin
class FileFilterPluginTest(unittest.TestCase, ImportHelper):
class FileFilterPluginTest(ImportTestCase):
def setUp(self):
self.setup_beets()
self.__create_import_dir(2)

View file

@ -19,7 +19,7 @@ import os
import unittest
from beets import importer
from beets.test.helper import AutotagStub, ImportHelper
from beets.test.helper import AutotagStub, ImportTestCase
from beets.util import displayable_path, syspath
from beetsplug.importadded import ImportAddedPlugin
@ -40,7 +40,7 @@ def modify_mtimes(paths, offset=-60000):
os.utime(syspath(path), (mstat.st_atime, mstat.st_mtime + offset * i))
class ImportAddedTest(unittest.TestCase, ImportHelper):
class ImportAddedTest(ImportTestCase):
# The minimum mtime of the files to be imported
min_mtime = None

View file

@ -17,17 +17,14 @@ import unittest
from beets.test.helper import (
AutotagStub,
BeetsTestCase,
ImportHelper,
ImportTestCase,
TerminalImportSessionSetup,
capture_stdout,
control_stdin,
)
class MBSubmitPluginTest(
TerminalImportSessionSetup, BeetsTestCase, ImportHelper
):
class MBSubmitPluginTest(TerminalImportSessionSetup, ImportTestCase):
def setUp(self):
self.setup_beets()
self.load_plugins("mbsubmit")

View file

@ -37,14 +37,14 @@ from beets.test import _common
from beets.test.helper import (
AutotagStub,
BeetsTestCase,
ImportHelper,
ImportTestCase,
capture_log,
has_program,
)
from beets.util import bytestring_path, displayable_path, syspath
class ScrubbedImportTest(BeetsTestCase, ImportHelper):
class ScrubbedImportTest(ImportTestCase):
def setUp(self):
self.setup_beets(disk=True)
self.load_plugins("scrub")
@ -99,7 +99,7 @@ class ScrubbedImportTest(BeetsTestCase, ImportHelper):
@_common.slow_test()
class NonAutotaggedImportTest(BeetsTestCase, ImportHelper):
class NonAutotaggedImportTest(ImportTestCase):
def setUp(self):
self.setup_beets(disk=True)
self._create_import_dir(2)
@ -271,7 +271,7 @@ def create_archive(session):
return path
class RmTempTest(unittest.TestCase, ImportHelper):
class RmTempTest(ImportTestCase):
"""Tests that temporarily extracted archives are properly removed
after usage.
"""
@ -296,7 +296,7 @@ class RmTempTest(unittest.TestCase, ImportHelper):
self.assertNotExists(tmp_path)
class ImportZipTest(unittest.TestCase, ImportHelper):
class ImportZipTest(ImportTestCase):
def setUp(self):
self.setup_beets()
@ -344,7 +344,7 @@ class ImportPasswordRarTest(ImportZipTest):
return os.path.join(_common.RSRC, b"password.rar")
class ImportSingletonTest(BeetsTestCase, ImportHelper):
class ImportSingletonTest(ImportTestCase):
"""Test ``APPLY`` and ``ASIS`` choices for an import session with
singletons config set to True.
"""
@ -467,7 +467,7 @@ class ImportSingletonTest(BeetsTestCase, ImportHelper):
self.assertEqual(item.title, "Applied Title 1 - formatted")
class ImportTest(BeetsTestCase, ImportHelper):
class ImportTest(ImportTestCase):
"""Test APPLY, ASIS and SKIP choices."""
def setUp(self):
@ -681,7 +681,7 @@ class ImportTest(BeetsTestCase, ImportHelper):
)
class ImportTracksTest(BeetsTestCase, ImportHelper):
class ImportTracksTest(ImportTestCase):
"""Test TRACKS and APPLY choice."""
def setUp(self):
@ -715,7 +715,7 @@ class ImportTracksTest(BeetsTestCase, ImportHelper):
self.assert_file_in_lib(b"singletons", b"Applied Title 1.mp3")
class ImportCompilationTest(BeetsTestCase, ImportHelper):
class ImportCompilationTest(ImportTestCase):
"""Test ASIS import of a folder containing tracks with different artists."""
def setUp(self):
@ -834,7 +834,7 @@ class ImportCompilationTest(BeetsTestCase, ImportHelper):
self.assertTrue(asserted_multi_artists_0 and asserted_multi_artists_1)
class ImportExistingTest(BeetsTestCase, ImportHelper):
class ImportExistingTest(ImportTestCase):
"""Test importing files that are already in the library directory."""
def setUp(self):
@ -959,7 +959,7 @@ class ImportExistingTest(BeetsTestCase, ImportHelper):
self.assertNotExists(self.import_media[0].path)
class GroupAlbumsImportTest(BeetsTestCase, ImportHelper):
class GroupAlbumsImportTest(ImportTestCase):
def setUp(self):
self.setup_beets()
self._create_import_dir(3)
@ -1031,7 +1031,7 @@ class GlobalGroupAlbumsImportTest(GroupAlbumsImportTest):
config["import"]["group_albums"] = True
class ChooseCandidateTest(BeetsTestCase, ImportHelper):
class ChooseCandidateTest(ImportTestCase):
def setUp(self):
self.setup_beets()
self._create_import_dir(1)
@ -1646,7 +1646,7 @@ class MultiDiscAlbumsInDirTest(BeetsTestCase):
self.assertEqual(len(items), 3)
class ReimportTest(unittest.TestCase, ImportHelper):
class ReimportTest(ImportTestCase):
"""Test "re-imports", in which the autotagging machinery is used for
music that's already in the library.
@ -1751,7 +1751,7 @@ class ReimportTest(unittest.TestCase, ImportHelper):
self.assertEqual(self._album().data_source, "match_source")
class ImportPretendTest(BeetsTestCase, ImportHelper):
class ImportPretendTest(ImportTestCase):
"""Test the pretend commandline option"""
def __init__(self, method_name="runTest"):
@ -1944,7 +1944,7 @@ def mocked_get_recording_by_id(
"musicbrainzngs.get_release_by_id",
Mock(side_effect=mocked_get_release_by_id),
)
class ImportMusicBrainzIdTest(BeetsTestCase, ImportHelper):
class ImportMusicBrainzIdTest(ImportTestCase):
"""Test the --musicbrainzid argument."""
MB_RELEASE_PREFIX = "https://musicbrainz.org/release/"