mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
Remove redundant library setUp instructions
This commit is contained in:
parent
2d5fd907c3
commit
7d7f16395c
13 changed files with 29 additions and 126 deletions
|
|
@ -470,11 +470,11 @@ class TestHelper(_common.Assertions):
|
||||||
|
|
||||||
# Safe file operations
|
# Safe file operations
|
||||||
|
|
||||||
def create_temp_dir(self):
|
def create_temp_dir(self, **kwargs):
|
||||||
"""Create a temporary directory and assign it into
|
"""Create a temporary directory and assign it into
|
||||||
`self.temp_dir`. Call `remove_temp_dir` later to delete it.
|
`self.temp_dir`. Call `remove_temp_dir` later to delete it.
|
||||||
"""
|
"""
|
||||||
temp_dir = mkdtemp()
|
temp_dir = mkdtemp(**kwargs)
|
||||||
self.temp_dir = util.bytestring_path(temp_dir)
|
self.temp_dir = util.bytestring_path(temp_dir)
|
||||||
|
|
||||||
def remove_temp_dir(self):
|
def remove_temp_dir(self):
|
||||||
|
|
@ -980,4 +980,3 @@ class CleanupModulesMixin:
|
||||||
"""Remove files created by the plugin."""
|
"""Remove files created by the plugin."""
|
||||||
for module in cls.modules:
|
for module in cls.modules:
|
||||||
clean_module_tempdir(module)
|
clean_module_tempdir(module)
|
||||||
self.lib = beets.library.Library(":memory:")
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ from unittest.mock import patch
|
||||||
import confuse
|
import confuse
|
||||||
import responses
|
import responses
|
||||||
|
|
||||||
from beets import config, importer, library, logging, util
|
from beets import config, importer, logging, util
|
||||||
from beets.autotag import AlbumInfo, AlbumMatch
|
from beets.autotag import AlbumInfo, AlbumMatch
|
||||||
from beets.test import _common
|
from beets.test import _common
|
||||||
from beets.test.helper import (
|
from beets.test.helper import (
|
||||||
|
|
@ -736,16 +736,12 @@ class ArtImporterTest(UseThePlugin):
|
||||||
self.plugin.art_for_album = art_for_album
|
self.plugin.art_for_album = art_for_album
|
||||||
|
|
||||||
# Test library.
|
# Test library.
|
||||||
self.libpath = os.path.join(self.temp_dir, b"tmplib.blb")
|
|
||||||
self.libdir = os.path.join(self.temp_dir, b"tmplib")
|
|
||||||
os.mkdir(syspath(self.libdir))
|
|
||||||
os.mkdir(syspath(os.path.join(self.libdir, b"album")))
|
os.mkdir(syspath(os.path.join(self.libdir, b"album")))
|
||||||
itempath = os.path.join(self.libdir, b"album", b"test.mp3")
|
itempath = os.path.join(self.libdir, b"album", b"test.mp3")
|
||||||
shutil.copyfile(
|
shutil.copyfile(
|
||||||
syspath(os.path.join(_common.RSRC, b"full.mp3")),
|
syspath(os.path.join(_common.RSRC, b"full.mp3")),
|
||||||
syspath(itempath),
|
syspath(itempath),
|
||||||
)
|
)
|
||||||
self.lib = library.Library(self.libpath)
|
|
||||||
self.i = _common.item()
|
self.i = _common.item()
|
||||||
self.i.path = itempath
|
self.i.path = itempath
|
||||||
self.album = self.lib.add_album([self.i])
|
self.album = self.lib.add_album([self.i])
|
||||||
|
|
@ -768,7 +764,6 @@ class ArtImporterTest(UseThePlugin):
|
||||||
self.task.set_choice(AlbumMatch(0, info, {}, set(), set()))
|
self.task.set_choice(AlbumMatch(0, info, {}, set(), set()))
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.lib._connection().close()
|
|
||||||
super().tearDown()
|
super().tearDown()
|
||||||
self.plugin.art_for_album = self.old_afa
|
self.plugin.art_for_album = self.old_afa
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
import unittest
|
import unittest
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
from beets import library
|
|
||||||
from beets.test import _common
|
from beets.test import _common
|
||||||
from beets.test.helper import BeetsTestCase
|
from beets.test.helper import BeetsTestCase
|
||||||
from beetsplug import beatport
|
from beetsplug import beatport
|
||||||
|
|
@ -452,7 +451,6 @@ class BeatportTest(BeetsTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.load_plugins("beatport")
|
self.load_plugins("beatport")
|
||||||
self.lib = library.Library(":memory:")
|
|
||||||
|
|
||||||
# Set up 'album'.
|
# Set up 'album'.
|
||||||
response_release = self._make_release_response()
|
response_release = self._make_release_response()
|
||||||
|
|
@ -630,7 +628,6 @@ class BeatportResponseEmptyTest(BeetsTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.load_plugins("beatport")
|
self.load_plugins("beatport")
|
||||||
self.lib = library.Library(":memory:")
|
|
||||||
|
|
||||||
# Set up 'tracks'.
|
# Set up 'tracks'.
|
||||||
self.response_tracks = self._make_tracks_response()
|
self.response_tracks = self._make_tracks_response()
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,21 @@
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import shutil
|
|
||||||
import tempfile
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from beets import config
|
from beets import config
|
||||||
from beets.library import Album, Item, Library
|
from beets.library import Album, Item
|
||||||
|
from beets.test.helper import BeetsTestCase
|
||||||
from beetsplug.importfeeds import ImportFeedsPlugin
|
from beetsplug.importfeeds import ImportFeedsPlugin
|
||||||
|
|
||||||
|
|
||||||
class ImportfeedsTestTest(unittest.TestCase):
|
class ImportfeedsTestTest(BeetsTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
config.clear()
|
super().setUp()
|
||||||
config.read(user=False)
|
|
||||||
self.importfeeds = ImportFeedsPlugin()
|
self.importfeeds = ImportFeedsPlugin()
|
||||||
self.lib = Library(":memory:")
|
self.feeds_dir = os.path.join(os.fsdecode(self.temp_dir), "importfeeds")
|
||||||
self.feeds_dir = tempfile.mkdtemp()
|
|
||||||
config["importfeeds"]["dir"] = self.feeds_dir
|
config["importfeeds"]["dir"] = self.feeds_dir
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
shutil.rmtree(self.feeds_dir)
|
|
||||||
|
|
||||||
def test_multi_format_album_playlist(self):
|
def test_multi_format_album_playlist(self):
|
||||||
config["importfeeds"]["formats"] = "m3u_multi"
|
config["importfeeds"]["formats"] = "m3u_multi"
|
||||||
album = Album(album="album/name", id=1)
|
album = Album(album="album/name", id=1)
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ import os
|
||||||
import unittest
|
import unittest
|
||||||
from unittest.mock import Mock, patch
|
from unittest.mock import Mock, patch
|
||||||
|
|
||||||
from beets import library
|
|
||||||
from beets.test import _common
|
from beets.test import _common
|
||||||
from beets.test.helper import BeetsTestCase
|
from beets.test.helper import BeetsTestCase
|
||||||
from beets.util import _fsencoding, bytestring_path
|
from beets.util import _fsencoding, bytestring_path
|
||||||
|
|
@ -28,7 +27,6 @@ class IPFSPluginTest(BeetsTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.load_plugins("ipfs")
|
self.load_plugins("ipfs")
|
||||||
self.lib = library.Library(":memory:")
|
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.unload_plugins()
|
self.unload_plugins()
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ from beets.test.helper import BeetsTestCase
|
||||||
class PlaylistTestCase(BeetsTestCase):
|
class PlaylistTestCase(BeetsTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.lib = beets.library.Library(":memory:")
|
|
||||||
|
|
||||||
self.music_dir = os.path.expanduser(os.path.join("~", "Music"))
|
self.music_dir = os.path.expanduser(os.path.join("~", "Music"))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,14 +41,10 @@ class MoveTest(BeetsTestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
# add it to a temporary library
|
# add it to a temporary library
|
||||||
self.lib = beets.library.Library(":memory:")
|
|
||||||
self.i = beets.library.Item.from_path(self.path)
|
self.i = beets.library.Item.from_path(self.path)
|
||||||
self.lib.add(self.i)
|
self.lib.add(self.i)
|
||||||
|
|
||||||
# set up the destination
|
# set up the destination
|
||||||
self.libdir = join(self.temp_dir, b"testlibdir")
|
|
||||||
os.mkdir(syspath(self.libdir))
|
|
||||||
self.lib.directory = self.libdir
|
|
||||||
self.lib.path_formats = [
|
self.lib.path_formats = [
|
||||||
("default", join("$artist", "$album", "$title"))
|
("default", join("$artist", "$album", "$title"))
|
||||||
]
|
]
|
||||||
|
|
@ -250,12 +246,9 @@ class AlbumFileTest(BeetsTestCase):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
# Make library and item.
|
# Make library and item.
|
||||||
self.lib = beets.library.Library(":memory:")
|
|
||||||
self.lib.path_formats = [
|
self.lib.path_formats = [
|
||||||
("default", join("$albumartist", "$album", "$title"))
|
("default", join("$albumartist", "$album", "$title"))
|
||||||
]
|
]
|
||||||
self.libdir = os.path.join(self.temp_dir, b"testlibdir")
|
|
||||||
self.lib.directory = self.libdir
|
|
||||||
self.i = item(self.lib)
|
self.i = item(self.lib)
|
||||||
# Make a file for the item.
|
# Make a file for the item.
|
||||||
self.i.path = self.i.destination()
|
self.i.path = self.i.destination()
|
||||||
|
|
@ -317,9 +310,6 @@ class ArtFileTest(BeetsTestCase):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
# Make library and item.
|
# Make library and item.
|
||||||
self.lib = beets.library.Library(":memory:")
|
|
||||||
self.libdir = os.path.join(self.temp_dir, b"testlibdir")
|
|
||||||
self.lib.directory = self.libdir
|
|
||||||
self.i = item(self.lib)
|
self.i = item(self.lib)
|
||||||
self.i.path = self.i.destination()
|
self.i.path = self.i.destination()
|
||||||
# Make a music file.
|
# Make a music file.
|
||||||
|
|
@ -491,9 +481,6 @@ class RemoveTest(BeetsTestCase):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
# Make library and item.
|
# Make library and item.
|
||||||
self.lib = beets.library.Library(":memory:")
|
|
||||||
self.libdir = os.path.join(self.temp_dir, b"testlibdir")
|
|
||||||
self.lib.directory = self.libdir
|
|
||||||
self.i = item(self.lib)
|
self.i = item(self.lib)
|
||||||
self.i.path = self.i.destination()
|
self.i.path = self.i.destination()
|
||||||
# Make a music file.
|
# Make a music file.
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,6 @@ class StoreTest(ItemInDBTestCase):
|
||||||
class AddTest(BeetsTestCase):
|
class AddTest(BeetsTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.lib = beets.library.Library(":memory:")
|
|
||||||
self.i = item()
|
self.i = item()
|
||||||
|
|
||||||
def test_item_add_inserts_row(self):
|
def test_item_add_inserts_row(self):
|
||||||
|
|
@ -155,9 +154,8 @@ class GetSetTest(BeetsTestCase):
|
||||||
|
|
||||||
def test_album_fallback(self):
|
def test_album_fallback(self):
|
||||||
# integration test of item-album fallback
|
# integration test of item-album fallback
|
||||||
lib = beets.library.Library(":memory:")
|
i = item(self.lib)
|
||||||
i = item(lib)
|
album = self.lib.add_album([i])
|
||||||
album = lib.add_album([i])
|
|
||||||
album["flex"] = "foo"
|
album["flex"] = "foo"
|
||||||
album.store()
|
album.store()
|
||||||
|
|
||||||
|
|
@ -170,18 +168,16 @@ class GetSetTest(BeetsTestCase):
|
||||||
|
|
||||||
|
|
||||||
class DestinationTest(BeetsTestCase):
|
class DestinationTest(BeetsTestCase):
|
||||||
|
"""Confirm tests handle temporary directory path containing '.'"""
|
||||||
|
|
||||||
|
def create_temp_dir(self, **kwargs):
|
||||||
|
kwargs["prefix"] = "."
|
||||||
|
super().create_temp_dir(**kwargs)
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
# default directory is ~/Music and the only reason why it was switched
|
|
||||||
# to ~/.Music is to confirm that tests works well when path to
|
|
||||||
# temporary directory contains .
|
|
||||||
self.lib = beets.library.Library(":memory:", "~/.Music")
|
|
||||||
self.i = item(self.lib)
|
self.i = item(self.lib)
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
super().tearDown()
|
|
||||||
self.lib._connection().close()
|
|
||||||
|
|
||||||
def test_directory_works_with_trailing_slash(self):
|
def test_directory_works_with_trailing_slash(self):
|
||||||
self.lib.directory = b"one/"
|
self.lib.directory = b"one/"
|
||||||
self.lib.path_formats = [("default", "two")]
|
self.lib.path_formats = [("default", "two")]
|
||||||
|
|
@ -623,15 +619,10 @@ class PathFormattingMixin:
|
||||||
class DestinationFunctionTest(BeetsTestCase, PathFormattingMixin):
|
class DestinationFunctionTest(BeetsTestCase, PathFormattingMixin):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.lib = beets.library.Library(":memory:")
|
|
||||||
self.lib.directory = b"/base"
|
self.lib.directory = b"/base"
|
||||||
self.lib.path_formats = [("default", "path")]
|
self.lib.path_formats = [("default", "path")]
|
||||||
self.i = item(self.lib)
|
self.i = item(self.lib)
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
super().tearDown()
|
|
||||||
self.lib._connection().close()
|
|
||||||
|
|
||||||
def test_upper_case_literal(self):
|
def test_upper_case_literal(self):
|
||||||
self._setf("%upper{foo}")
|
self._setf("%upper{foo}")
|
||||||
self._assert_dest(b"/base/FOO")
|
self._assert_dest(b"/base/FOO")
|
||||||
|
|
@ -732,7 +723,6 @@ class DestinationFunctionTest(BeetsTestCase, PathFormattingMixin):
|
||||||
class DisambiguationTest(BeetsTestCase, PathFormattingMixin):
|
class DisambiguationTest(BeetsTestCase, PathFormattingMixin):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.lib = beets.library.Library(":memory:")
|
|
||||||
self.lib.directory = b"/base"
|
self.lib.directory = b"/base"
|
||||||
self.lib.path_formats = [("default", "path")]
|
self.lib.path_formats = [("default", "path")]
|
||||||
|
|
||||||
|
|
@ -746,10 +736,6 @@ class DisambiguationTest(BeetsTestCase, PathFormattingMixin):
|
||||||
|
|
||||||
self._setf("foo%aunique{albumartist album,year}/$title")
|
self._setf("foo%aunique{albumartist album,year}/$title")
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
super().tearDown()
|
|
||||||
self.lib._connection().close()
|
|
||||||
|
|
||||||
def test_unique_expands_to_disambiguating_year(self):
|
def test_unique_expands_to_disambiguating_year(self):
|
||||||
self._assert_dest(b"/base/foo [2001]/the title", self.i1)
|
self._assert_dest(b"/base/foo [2001]/the title", self.i1)
|
||||||
|
|
||||||
|
|
@ -821,7 +807,6 @@ class DisambiguationTest(BeetsTestCase, PathFormattingMixin):
|
||||||
class SingletonDisambiguationTest(BeetsTestCase, PathFormattingMixin):
|
class SingletonDisambiguationTest(BeetsTestCase, PathFormattingMixin):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.lib = beets.library.Library(":memory:")
|
|
||||||
self.lib.directory = b"/base"
|
self.lib.directory = b"/base"
|
||||||
self.lib.path_formats = [("default", "path")]
|
self.lib.path_formats = [("default", "path")]
|
||||||
|
|
||||||
|
|
@ -835,10 +820,6 @@ class SingletonDisambiguationTest(BeetsTestCase, PathFormattingMixin):
|
||||||
|
|
||||||
self._setf("foo/$title%sunique{artist title,year}")
|
self._setf("foo/$title%sunique{artist title,year}")
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
super().tearDown()
|
|
||||||
self.lib._connection().close()
|
|
||||||
|
|
||||||
def test_sunique_expands_to_disambiguating_year(self):
|
def test_sunique_expands_to_disambiguating_year(self):
|
||||||
self._assert_dest(b"/base/foo/the title [2001]", self.i1)
|
self._assert_dest(b"/base/foo/the title [2001]", self.i1)
|
||||||
|
|
||||||
|
|
@ -919,7 +900,6 @@ class PluginDestinationTest(BeetsTestCase):
|
||||||
self.old_field_getters = plugins.item_field_getters
|
self.old_field_getters = plugins.item_field_getters
|
||||||
plugins.item_field_getters = field_getters
|
plugins.item_field_getters = field_getters
|
||||||
|
|
||||||
self.lib = beets.library.Library(":memory:")
|
|
||||||
self.lib.directory = b"/base"
|
self.lib.directory = b"/base"
|
||||||
self.lib.path_formats = [("default", "$artist $foo")]
|
self.lib.path_formats = [("default", "$artist $foo")]
|
||||||
self.i = item(self.lib)
|
self.i = item(self.lib)
|
||||||
|
|
@ -958,7 +938,6 @@ class PluginDestinationTest(BeetsTestCase):
|
||||||
class AlbumInfoTest(BeetsTestCase):
|
class AlbumInfoTest(BeetsTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.lib = beets.library.Library(":memory:")
|
|
||||||
self.i = item()
|
self.i = item()
|
||||||
self.lib.add_album((self.i,))
|
self.lib.add_album((self.i,))
|
||||||
|
|
||||||
|
|
@ -1065,9 +1044,7 @@ class ArtDestinationTest(BeetsTestCase):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
config["art_filename"] = "artimage"
|
config["art_filename"] = "artimage"
|
||||||
config["replace"] = {"X": "Y"}
|
config["replace"] = {"X": "Y"}
|
||||||
self.lib = beets.library.Library(
|
self.lib.replacements = [(re.compile("X"), "Y")]
|
||||||
":memory:", replacements=[(re.compile("X"), "Y")]
|
|
||||||
)
|
|
||||||
self.i = item(self.lib)
|
self.i = item(self.lib)
|
||||||
self.i.path = self.i.destination()
|
self.i.path = self.i.destination()
|
||||||
self.ai = self.lib.add_album((self.i,))
|
self.ai = self.lib.add_album((self.i,))
|
||||||
|
|
@ -1091,7 +1068,6 @@ class ArtDestinationTest(BeetsTestCase):
|
||||||
class PathStringTest(BeetsTestCase):
|
class PathStringTest(BeetsTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.lib = beets.library.Library(":memory:")
|
|
||||||
self.i = item(self.lib)
|
self.i = item(self.lib)
|
||||||
|
|
||||||
def test_item_path_is_bytestring(self):
|
def test_item_path_is_bytestring(self):
|
||||||
|
|
@ -1183,7 +1159,6 @@ class MtimeTest(BeetsTestCase):
|
||||||
syspath(self.ipath),
|
syspath(self.ipath),
|
||||||
)
|
)
|
||||||
self.i = beets.library.Item.from_path(self.ipath)
|
self.i = beets.library.Item.from_path(self.ipath)
|
||||||
self.lib = beets.library.Library(":memory:")
|
|
||||||
self.lib.add(self.i)
|
self.lib.add(self.i)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
|
@ -1213,10 +1188,6 @@ class MtimeTest(BeetsTestCase):
|
||||||
|
|
||||||
|
|
||||||
class ImportTimeTest(BeetsTestCase):
|
class ImportTimeTest(BeetsTestCase):
|
||||||
def setUp(self):
|
|
||||||
super().setUp()
|
|
||||||
self.lib = beets.library.Library(":memory:")
|
|
||||||
|
|
||||||
def added(self):
|
def added(self):
|
||||||
self.track = item()
|
self.track = item()
|
||||||
self.album = self.lib.add_album((self.track,))
|
self.album = self.lib.add_album((self.track,))
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ from beets.dbcore.query import (
|
||||||
NoneQuery,
|
NoneQuery,
|
||||||
ParsingError,
|
ParsingError,
|
||||||
)
|
)
|
||||||
from beets.library import Item, Library
|
from beets.library import Item
|
||||||
from beets.test import _common
|
from beets.test import _common
|
||||||
from beets.test.helper import BeetsTestCase, ItemInDBTestCase
|
from beets.test.helper import BeetsTestCase, ItemInDBTestCase
|
||||||
from beets.util import syspath
|
from beets.util import syspath
|
||||||
|
|
@ -94,7 +94,6 @@ class AnyFieldQueryTest(ItemInDBTestCase):
|
||||||
class DummyDataTestCase(BeetsTestCase, AssertsMixin):
|
class DummyDataTestCase(BeetsTestCase, AssertsMixin):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.lib = beets.library.Library(":memory:")
|
|
||||||
items = [_common.item() for _ in range(3)]
|
items = [_common.item() for _ in range(3)]
|
||||||
items[0].title = "foo bar"
|
items[0].title = "foo bar"
|
||||||
items[0].artist = "one"
|
items[0].artist = "one"
|
||||||
|
|
@ -725,9 +724,6 @@ class PathQueryTest(ItemInDBTestCase, AssertsMixin):
|
||||||
|
|
||||||
|
|
||||||
class IntQueryTest(BeetsTestCase):
|
class IntQueryTest(BeetsTestCase):
|
||||||
def setUp(self):
|
|
||||||
self.lib = Library(":memory:")
|
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
super().tearDown()
|
super().tearDown()
|
||||||
Item._types = {}
|
Item._types = {}
|
||||||
|
|
@ -766,7 +762,6 @@ class IntQueryTest(BeetsTestCase):
|
||||||
class BoolQueryTest(BeetsTestCase, AssertsMixin):
|
class BoolQueryTest(BeetsTestCase, AssertsMixin):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.lib = Library(":memory:")
|
|
||||||
Item._types = {"flexbool": types.Boolean()}
|
Item._types = {"flexbool": types.Boolean()}
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
|
@ -836,10 +831,6 @@ class DefaultSearchFieldsTest(DummyDataTestCase):
|
||||||
|
|
||||||
|
|
||||||
class NoneQueryTest(BeetsTestCase, AssertsMixin):
|
class NoneQueryTest(BeetsTestCase, AssertsMixin):
|
||||||
def setUp(self):
|
|
||||||
super().setUp()
|
|
||||||
self.lib = Library(":memory:")
|
|
||||||
|
|
||||||
def test_match_singletons(self):
|
def test_match_singletons(self):
|
||||||
singleton = self.add_item()
|
singleton = self.add_item()
|
||||||
album_item = self.add_album().items().get()
|
album_item = self.add_album().items().get()
|
||||||
|
|
@ -1137,7 +1128,6 @@ class RelatedQueriesTest(BeetsTestCase, AssertsMixin):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.lib = beets.library.Library(":memory:")
|
|
||||||
|
|
||||||
albums = []
|
albums = []
|
||||||
for album_idx in range(1, 3):
|
for album_idx in range(1, 3):
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@ from beets.test.helper import BeetsTestCase
|
||||||
class DummyDataTestCase(BeetsTestCase):
|
class DummyDataTestCase(BeetsTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.lib = beets.library.Library(":memory:")
|
|
||||||
|
|
||||||
albums = [_common.album() for _ in range(3)]
|
albums = [_common.album() for _ in range(3)]
|
||||||
albums[0].album = "Album A"
|
albums[0].album = "Album A"
|
||||||
|
|
|
||||||
|
|
@ -40,9 +40,9 @@ from beets.ui import commands
|
||||||
from beets.util import MoveOperation, syspath
|
from beets.util import MoveOperation, syspath
|
||||||
|
|
||||||
|
|
||||||
class ListTest(unittest.TestCase):
|
class ListTest(BeetsTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.lib = library.Library(":memory:")
|
super().setUp()
|
||||||
self.item = _common.item()
|
self.item = _common.item()
|
||||||
self.item.path = "xxx/yyy"
|
self.item.path = "xxx/yyy"
|
||||||
self.lib.add(self.item)
|
self.lib.add(self.item)
|
||||||
|
|
@ -114,11 +114,7 @@ class RemoveTest(BeetsTestCase):
|
||||||
|
|
||||||
self.io.install()
|
self.io.install()
|
||||||
|
|
||||||
self.libdir = os.path.join(self.temp_dir, b"testlibdir")
|
|
||||||
os.mkdir(syspath(self.libdir))
|
|
||||||
|
|
||||||
# Copy a file into the library.
|
# Copy a file into the library.
|
||||||
self.lib = library.Library(":memory:", self.libdir)
|
|
||||||
self.item_path = os.path.join(_common.RSRC, b"full.mp3")
|
self.item_path = os.path.join(_common.RSRC, b"full.mp3")
|
||||||
self.i = library.Item.from_path(self.item_path)
|
self.i = library.Item.from_path(self.item_path)
|
||||||
self.lib.add(self.i)
|
self.lib.add(self.i)
|
||||||
|
|
@ -451,9 +447,6 @@ class MoveTest(BeetsTestCase):
|
||||||
|
|
||||||
self.io.install()
|
self.io.install()
|
||||||
|
|
||||||
self.libdir = os.path.join(self.temp_dir, b"testlibdir")
|
|
||||||
os.mkdir(syspath(self.libdir))
|
|
||||||
|
|
||||||
self.itempath = os.path.join(self.libdir, b"srcfile")
|
self.itempath = os.path.join(self.libdir, b"srcfile")
|
||||||
shutil.copy(
|
shutil.copy(
|
||||||
syspath(os.path.join(_common.RSRC, b"full.mp3")),
|
syspath(os.path.join(_common.RSRC, b"full.mp3")),
|
||||||
|
|
@ -461,7 +454,6 @@ class MoveTest(BeetsTestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add a file to the library but don't copy it in yet.
|
# Add a file to the library but don't copy it in yet.
|
||||||
self.lib = library.Library(":memory:", self.libdir)
|
|
||||||
self.i = library.Item.from_path(self.itempath)
|
self.i = library.Item.from_path(self.itempath)
|
||||||
self.lib.add(self.i)
|
self.lib.add(self.i)
|
||||||
self.album = self.lib.add_album([self.i])
|
self.album = self.lib.add_album([self.i])
|
||||||
|
|
@ -485,28 +477,28 @@ class MoveTest(BeetsTestCase):
|
||||||
def test_move_item(self):
|
def test_move_item(self):
|
||||||
self._move()
|
self._move()
|
||||||
self.i.load()
|
self.i.load()
|
||||||
self.assertIn(b"testlibdir", self.i.path)
|
self.assertIn(b"libdir", self.i.path)
|
||||||
self.assertExists(self.i.path)
|
self.assertExists(self.i.path)
|
||||||
self.assertNotExists(self.itempath)
|
self.assertNotExists(self.itempath)
|
||||||
|
|
||||||
def test_copy_item(self):
|
def test_copy_item(self):
|
||||||
self._move(copy=True)
|
self._move(copy=True)
|
||||||
self.i.load()
|
self.i.load()
|
||||||
self.assertIn(b"testlibdir", self.i.path)
|
self.assertIn(b"libdir", self.i.path)
|
||||||
self.assertExists(self.i.path)
|
self.assertExists(self.i.path)
|
||||||
self.assertExists(self.itempath)
|
self.assertExists(self.itempath)
|
||||||
|
|
||||||
def test_move_album(self):
|
def test_move_album(self):
|
||||||
self._move(album=True)
|
self._move(album=True)
|
||||||
self.i.load()
|
self.i.load()
|
||||||
self.assertIn(b"testlibdir", self.i.path)
|
self.assertIn(b"libdir", self.i.path)
|
||||||
self.assertExists(self.i.path)
|
self.assertExists(self.i.path)
|
||||||
self.assertNotExists(self.itempath)
|
self.assertNotExists(self.itempath)
|
||||||
|
|
||||||
def test_copy_album(self):
|
def test_copy_album(self):
|
||||||
self._move(copy=True, album=True)
|
self._move(copy=True, album=True)
|
||||||
self.i.load()
|
self.i.load()
|
||||||
self.assertIn(b"testlibdir", self.i.path)
|
self.assertIn(b"libdir", self.i.path)
|
||||||
self.assertExists(self.i.path)
|
self.assertExists(self.i.path)
|
||||||
self.assertExists(self.itempath)
|
self.assertExists(self.itempath)
|
||||||
|
|
||||||
|
|
@ -559,10 +551,7 @@ class UpdateTest(BeetsTestCase):
|
||||||
|
|
||||||
self.io.install()
|
self.io.install()
|
||||||
|
|
||||||
self.libdir = os.path.join(self.temp_dir, b"testlibdir")
|
|
||||||
|
|
||||||
# Copy a file into the library.
|
# Copy a file into the library.
|
||||||
self.lib = library.Library(":memory:", self.libdir)
|
|
||||||
item_path = os.path.join(_common.RSRC, b"full.mp3")
|
item_path = os.path.join(_common.RSRC, b"full.mp3")
|
||||||
item_path_two = os.path.join(_common.RSRC, b"full.flac")
|
item_path_two = os.path.join(_common.RSRC, b"full.flac")
|
||||||
self.i = library.Item.from_path(item_path)
|
self.i = library.Item.from_path(item_path)
|
||||||
|
|
|
||||||
|
|
@ -28,18 +28,6 @@ from beets.util import syspath
|
||||||
|
|
||||||
|
|
||||||
class QueryTest(BeetsTestCase):
|
class QueryTest(BeetsTestCase):
|
||||||
def setUp(self):
|
|
||||||
super().setUp()
|
|
||||||
|
|
||||||
self.libdir = os.path.join(self.temp_dir, b"testlibdir")
|
|
||||||
os.mkdir(syspath(self.libdir))
|
|
||||||
|
|
||||||
# Add a file to the library but don't copy it in yet.
|
|
||||||
self.lib = library.Library(":memory:", self.libdir)
|
|
||||||
|
|
||||||
# Alternate destination directory.
|
|
||||||
# self.otherdir = os.path.join(self.temp_dir, b"testotherdir")
|
|
||||||
|
|
||||||
def add_item(self, filename=b"srcfile", templatefile=b"full.mp3"):
|
def add_item(self, filename=b"srcfile", templatefile=b"full.mp3"):
|
||||||
itempath = os.path.join(self.libdir, filename)
|
itempath = os.path.join(self.libdir, filename)
|
||||||
shutil.copy(
|
shutil.copy(
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from beets import library, vfs
|
from beets import vfs
|
||||||
from beets.test import _common
|
from beets.test import _common
|
||||||
from beets.test.helper import BeetsTestCase
|
from beets.test.helper import BeetsTestCase
|
||||||
|
|
||||||
|
|
@ -24,13 +24,10 @@ from beets.test.helper import BeetsTestCase
|
||||||
class VFSTest(BeetsTestCase):
|
class VFSTest(BeetsTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.lib = library.Library(
|
self.lib.path_formats = [
|
||||||
":memory:",
|
|
||||||
path_formats=[
|
|
||||||
("default", "albums/$album/$title"),
|
("default", "albums/$album/$title"),
|
||||||
("singleton:true", "tracks/$artist/$title"),
|
("singleton:true", "tracks/$artist/$title"),
|
||||||
],
|
]
|
||||||
)
|
|
||||||
self.lib.add(_common.item())
|
self.lib.add(_common.item())
|
||||||
self.lib.add_album([_common.item()])
|
self.lib.add_album([_common.item()])
|
||||||
self.tree = vfs.libtree(self.lib)
|
self.tree = vfs.libtree(self.lib)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue