Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ jobs:
- "beets@git+https://github.com/beetbox/beets#master"
- "beets==2.0.*"
- "beets==2.1.*"
- "beets==2.2.*"
- "beets==2.3.*"

runs-on: ubuntu-latest
continue-on-error: ${{ endsWith(matrix.beets, 'master') }}
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- Add support for beets 2.4
- Drop support for Python 3.9 and beets<2

## v0.15.0 2024-09-20
Expand Down
8 changes: 7 additions & 1 deletion beetsplug/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
from beets.ui import Subcommand, UserError, colorize, decargs, input_yn
from beets.util import displayable_path, syspath

try:
from beets.importer import Action as ImporterAction
except ImportError:
# beets<2.4 compatibility
from beets.importer import action as ImporterAction

log = logging.getLogger("beets.check")


Expand Down Expand Up @@ -155,7 +161,7 @@ def verify_import_integrity(self, session, task):
"Do you want to skip this album (Y/n)"
):
log.info("Skipping.")
task.choice_flag = importer.action.SKIP
task.choice_flag = ImporterAction.SKIP


class CheckCommand(Subcommand):
Expand Down
43 changes: 30 additions & 13 deletions test/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
import shutil
import sys
import tempfile
from collections import defaultdict
from contextlib import contextmanager

try:
from StringIO import StringIO
except ImportError:
from io import StringIO
from io import StringIO

import beets
from beets import autotag, plugins
Expand All @@ -20,14 +17,23 @@
TrackInfo,
TrackMatch,
)
from beets.autotag.hooks import Distance

try:
from beets.autotag.distance import Distance
except ImportError:
# beets<2.4 compatibility
from beets.autotag.hooks import Distance

import beets.plugins
from beets.library import Item
from mediafile import MediaFile

from beetsplug import check
from beetsplug import check, convert

logging.getLogger("beets").propagate = True

_beets_version = tuple(map(int, beets.__version__.split(".")[0:3]))


class LogCapture(logging.Handler):
def __init__(self):
Expand Down Expand Up @@ -72,7 +78,6 @@ def controlStdin(input=None):
class TestHelper:
def setUp(self):
self.temp_dir = tempfile.mkdtemp()
plugins._classes = {check.CheckPlugin}
self.disableIntegrityCheckers()

def tearDown(self):
Expand Down Expand Up @@ -102,6 +107,15 @@ def setupBeets(self):
self.config["library"].as_filename(), self.libdir
)

if _beets_version > (2, 3, 1):
beets.plugins._instances = [
check.CheckPlugin(),
convert.ConvertPlugin(),
]
else:
beets.plugins._classes = {check.CheckPlugin, convert.ConvertPlugin}
beets.plugins._instances = {}

self.fixture_dir = os.path.join(os.path.dirname(__file__), "fixtures")

def setupImportDir(self, files):
Expand Down Expand Up @@ -167,10 +181,13 @@ def mockAutotag(self):
mock.restore()

def unloadPlugins(self):
for plugin in plugins._classes:
plugin.listeners = None
plugins._classes = set()
plugins._instances = {}
if _beets_version > (2, 3, 1):
beets.plugins.BeetsPlugin.listeners = defaultdict(list)
else:
for plugin in beets.plugins._classes: # type: ignore (compatibility with beets<2.4)
# Instantiating a plugin will modify register event listeners which
# are stored in a class variable
plugin.listeners = None # type: ignore (compatibility with beets<2.4)


class AutotagMock:
Expand Down Expand Up @@ -208,7 +225,7 @@ def tag_album(self, items, **kwargs):
album_id=self.nextid(),
artist="artist",
artist_id=self.nextid(),
tracks=mapping.values(),
tracks=list(mapping.values()),
)
match = AlbumMatch(
distance=dist,
Expand Down
3 changes: 0 additions & 3 deletions test/integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,6 @@ class ConvertTest(TestHelper, TestCase):
def setUp(self):
super().setUp()
self.setupBeets()
beets.config["plugins"] = ["convert"]
beets.plugins._instances.clear()
beets.plugins.load_plugins(("convert", "check"))

beets.config["convert"] = {
"dest": os.path.join(self.temp_dir, "convert"),
Expand Down
Loading
Loading