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:
|
||||
@pytest.fixture(scope="class")
|
||||
def config(self):
|
||||
return ConfigMixin().config
|
||||
|
||||
@pytest.fixture
|
||||
def dist(self, config):
|
||||
@pytest.fixture(autouse=True, scope="class")
|
||||
def setup_config(self):
|
||||
config = ConfigMixin().config
|
||||
config["match"]["distance_weights"]["data_source"] = 2.0
|
||||
config["match"]["distance_weights"]["album"] = 4.0
|
||||
config["match"]["distance_weights"]["medium"] = 2.0
|
||||
|
||||
@pytest.fixture
|
||||
def dist(self):
|
||||
return Distance()
|
||||
|
||||
def test_add(self, dist):
|
||||
|
|
@ -161,10 +160,8 @@ class TestTrackDistance:
|
|||
def test_track_distance(self, info, title, artist, expected_penalty):
|
||||
item = Item(artist=artist, title=title)
|
||||
|
||||
assert (
|
||||
bool(track_distance(item, info, incl_artist=True))
|
||||
== expected_penalty
|
||||
)
|
||||
dist = track_distance(item, info, incl_artist=True)
|
||||
assert bool(dist) == expected_penalty, dist._penalties
|
||||
|
||||
|
||||
class TestAlbumDistance:
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import os
|
|||
|
||||
import pytest
|
||||
|
||||
from beets.autotag.distance import Distance
|
||||
from beets.dbcore.query import Query
|
||||
from beets.util import cached_classproperty
|
||||
|
||||
|
|
@ -44,6 +45,11 @@ def pytest_make_parametrize_id(config, val, argname):
|
|||
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)
|
||||
def clear_cached_classproperty():
|
||||
cached_classproperty.cache.clear()
|
||||
|
|
|
|||
Loading…
Reference in a new issue