From e6895bb52d3e4233fe76dedcd2ba6bbcb8b4f7f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0ar=C5=ABnas=20Nejus?= Date: Mon, 6 Oct 2025 09:00:46 +0100 Subject: [PATCH] Reset cached_classproperty cache for every test --- beets/test/helper.py | 2 -- test/autotag/test_distance.py | 2 -- test/conftest.py | 6 ++++++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/beets/test/helper.py b/beets/test/helper.py index 85adc0825..ea08ec840 100644 --- a/beets/test/helper.py +++ b/beets/test/helper.py @@ -58,7 +58,6 @@ from beets.ui.commands import TerminalImportSession from beets.util import ( MoveOperation, bytestring_path, - cached_classproperty, clean_module_tempdir, syspath, ) @@ -495,7 +494,6 @@ class PluginMixin(ConfigMixin): # FIXME this should eventually be handled by a plugin manager plugins = (self.plugin,) if hasattr(self, "plugin") else plugins self.config["plugins"] = plugins - cached_classproperty.cache.clear() beets.plugins.load_plugins() def unload_plugins(self) -> None: diff --git a/test/autotag/test_distance.py b/test/autotag/test_distance.py index 5a3a8bee2..8c4478ca9 100644 --- a/test/autotag/test_distance.py +++ b/test/autotag/test_distance.py @@ -27,8 +27,6 @@ class TestDistance: config["match"]["distance_weights"]["album"] = 4.0 config["match"]["distance_weights"]["medium"] = 2.0 - Distance.__dict__["_weights"].cache = {} - return Distance() def test_add(self, dist): diff --git a/test/conftest.py b/test/conftest.py index 3107ad690..e1350b092 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -4,6 +4,7 @@ import os import pytest from beets.dbcore.query import Query +from beets.util import cached_classproperty def skip_marked_items(items: list[pytest.Item], marker_name: str, reason: str): @@ -41,3 +42,8 @@ def pytest_make_parametrize_id(config, val, argname): return inspect.getsource(val).split("lambda")[-1][:30] return repr(val) + + +@pytest.fixture(autouse=True) +def clear_cached_classproperty(): + cached_classproperty.cache.clear()