mirror of
https://github.com/beetbox/beets.git
synced 2026-01-08 08:56:56 +01:00
Define a shared fixture for config
This commit is contained in:
parent
75baec611a
commit
c807effeda
5 changed files with 15 additions and 22 deletions
|
|
@ -12,15 +12,13 @@ from beets.autotag.distance import (
|
|||
from beets.library import Item
|
||||
from beets.metadata_plugins import MetadataSourcePlugin, get_penalty
|
||||
from beets.plugins import BeetsPlugin
|
||||
from beets.test.helper import ConfigMixin
|
||||
|
||||
_p = pytest.param
|
||||
|
||||
|
||||
class TestDistance:
|
||||
@pytest.fixture(autouse=True, scope="class")
|
||||
def setup_config(self):
|
||||
config = ConfigMixin().config
|
||||
def setup_config(self, config):
|
||||
config["match"]["distance_weights"]["data_source"] = 2.0
|
||||
config["match"]["distance_weights"]["album"] = 4.0
|
||||
config["match"]["distance_weights"]["medium"] = 2.0
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import pytest
|
|||
|
||||
from beets.autotag.distance import Distance
|
||||
from beets.dbcore.query import Query
|
||||
from beets.test.helper import ConfigMixin
|
||||
from beets.util import cached_classproperty
|
||||
|
||||
|
||||
|
|
@ -53,3 +54,9 @@ def pytest_assertrepr_compare(op, left, right):
|
|||
@pytest.fixture(autouse=True)
|
||||
def clear_cached_classproperty():
|
||||
cached_classproperty.cache.clear()
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def config():
|
||||
"""Provide a fresh beets configuration for a module, when requested."""
|
||||
return ConfigMixin().config
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from beets.autotag import AlbumMatch
|
|||
from beets.autotag.distance import Distance
|
||||
from beets.autotag.hooks import AlbumInfo, TrackInfo
|
||||
from beets.library import Item
|
||||
from beets.test.helper import ConfigMixin, PluginMixin
|
||||
from beets.test.helper import PluginMixin
|
||||
from beetsplug._typing import JSONDict
|
||||
from beetsplug.mbpseudo import (
|
||||
_STATUS_PSEUDO,
|
||||
|
|
@ -52,14 +52,7 @@ def pseudo_release_info() -> AlbumInfo:
|
|||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", autouse=True)
|
||||
def config():
|
||||
config = ConfigMixin().config
|
||||
with pytest.MonkeyPatch.context() as m:
|
||||
m.setattr("beetsplug.mbpseudo.config", config)
|
||||
yield config
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("config")
|
||||
class TestPseudoAlbumInfo:
|
||||
def test_album_id_always_from_pseudo(
|
||||
self, official_release_info: AlbumInfo, pseudo_release_info: AlbumInfo
|
||||
|
|
|
|||
|
|
@ -19,18 +19,18 @@ import pytest
|
|||
from beets import autotag, config
|
||||
from beets.autotag import AlbumInfo, TrackInfo, correct_list_fields, match
|
||||
from beets.library import Item
|
||||
from beets.test.helper import BeetsTestCase, ConfigMixin
|
||||
from beets.test.helper import BeetsTestCase
|
||||
|
||||
|
||||
class TestAssignment(ConfigMixin):
|
||||
class TestAssignment:
|
||||
A = "one"
|
||||
B = "two"
|
||||
C = "three"
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _setup_config(self):
|
||||
self.config["match"]["track_length_grace"] = 10
|
||||
self.config["match"]["track_length_max"] = 30
|
||||
def config(self, config):
|
||||
config["match"]["track_length_grace"] = 10
|
||||
config["match"]["track_length_max"] = 30
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
# 'expected' is a tuple of expected (mapping, extra_items, extra_tracks)
|
||||
|
|
|
|||
|
|
@ -1,17 +1,12 @@
|
|||
import pytest
|
||||
|
||||
from beets.library import Item
|
||||
from beets.test.helper import ConfigMixin
|
||||
from beets.ui import _field_diff
|
||||
|
||||
p = pytest.param
|
||||
|
||||
|
||||
class TestFieldDiff:
|
||||
@pytest.fixture(scope="class", autouse=True)
|
||||
def config(self):
|
||||
return ConfigMixin().config
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def configure_color(self, config, color):
|
||||
config["ui"]["color"] = color
|
||||
|
|
|
|||
Loading…
Reference in a new issue