diff --git a/beets/library.py b/beets/library.py index 9be3a1602..b813d2ba4 100644 --- a/beets/library.py +++ b/beets/library.py @@ -1084,7 +1084,9 @@ class Item(LibModel): (i.e., where the file ought to be). The path is returned as a bytestring. ``basedir`` can override the - library's base directory for the destination. + library's base directory for the destination. If ``relative_to_libdir`` + is true, returns just the fragment of the path underneath the library + base directory. """ db = self._check_db() basedir = basedir or db.directory diff --git a/docs/changelog.rst b/docs/changelog.rst index 09259e1fa..9bc065419 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -28,6 +28,8 @@ Bug fixes: * :doc:`plugins/musicbrainz`: fix regression where user configured ``extra_tags`` have been read incorrectly. :bug:`5788` +* tests: Fix library tests failing on Windows when run from outside ``D:/``. + :bug:`5802` For packagers: diff --git a/test/test_library.py b/test/test_library.py index 39f1d0b9e..bb014d76d 100644 --- a/test/test_library.py +++ b/test/test_library.py @@ -34,7 +34,7 @@ from beets.library import Album from beets.test import _common from beets.test._common import item from beets.test.helper import BeetsTestCase, ItemInDBTestCase -from beets.util import as_string, bytestring_path, syspath +from beets.util import as_string, bytestring_path, normpath, syspath # Shortcut to path normalization. np = util.normpath @@ -553,6 +553,9 @@ class ItemFormattedMappingTest(ItemInDBTestCase): class PathFormattingMixin: """Utilities for testing path formatting.""" + i: beets.library.Item + lib: beets.library.Library + def _setf(self, fmt): self.lib.path_formats.insert(0, ("default", fmt)) @@ -560,9 +563,12 @@ class PathFormattingMixin: if i is None: i = self.i + # Handle paths on Windows. if os.path.sep != "/": dest = dest.replace(b"/", os.path.sep.encode()) - dest = b"D:" + dest + + # Paths are normalized based on the CWD. + dest = normpath(dest) actual = i.destination()