mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 00:24:25 +01:00
Improve visibility of Distance tests failures
This commit is contained in:
parent
e6895bb52d
commit
5757579e27
2 changed files with 13 additions and 10 deletions
|
|
@ -17,16 +17,15 @@ _p = pytest.param
|
||||||
|
|
||||||
|
|
||||||
class TestDistance:
|
class TestDistance:
|
||||||
@pytest.fixture(scope="class")
|
@pytest.fixture(autouse=True, scope="class")
|
||||||
def config(self):
|
def setup_config(self):
|
||||||
return ConfigMixin().config
|
config = ConfigMixin().config
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def dist(self, config):
|
|
||||||
config["match"]["distance_weights"]["data_source"] = 2.0
|
config["match"]["distance_weights"]["data_source"] = 2.0
|
||||||
config["match"]["distance_weights"]["album"] = 4.0
|
config["match"]["distance_weights"]["album"] = 4.0
|
||||||
config["match"]["distance_weights"]["medium"] = 2.0
|
config["match"]["distance_weights"]["medium"] = 2.0
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def dist(self):
|
||||||
return Distance()
|
return Distance()
|
||||||
|
|
||||||
def test_add(self, dist):
|
def test_add(self, dist):
|
||||||
|
|
@ -161,10 +160,8 @@ class TestTrackDistance:
|
||||||
def test_track_distance(self, info, title, artist, expected_penalty):
|
def test_track_distance(self, info, title, artist, expected_penalty):
|
||||||
item = Item(artist=artist, title=title)
|
item = Item(artist=artist, title=title)
|
||||||
|
|
||||||
assert (
|
dist = track_distance(item, info, incl_artist=True)
|
||||||
bool(track_distance(item, info, incl_artist=True))
|
assert bool(dist) == expected_penalty, dist._penalties
|
||||||
== expected_penalty
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class TestAlbumDistance:
|
class TestAlbumDistance:
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import os
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from beets.autotag.distance import Distance
|
||||||
from beets.dbcore.query import Query
|
from beets.dbcore.query import Query
|
||||||
from beets.util import cached_classproperty
|
from beets.util import cached_classproperty
|
||||||
|
|
||||||
|
|
@ -44,6 +45,11 @@ def pytest_make_parametrize_id(config, val, argname):
|
||||||
return repr(val)
|
return repr(val)
|
||||||
|
|
||||||
|
|
||||||
|
def pytest_assertrepr_compare(op, left, right):
|
||||||
|
if isinstance(left, Distance) or isinstance(right, Distance):
|
||||||
|
return [f"Comparing Distance: {float(left)} {op} {float(right)}"]
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def clear_cached_classproperty():
|
def clear_cached_classproperty():
|
||||||
cached_classproperty.cache.clear()
|
cached_classproperty.cache.clear()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue