mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
[Test] Fix path tests on windows (#5803)
## Description Fixes #5802. Today, tests fail on most Windows machines because we hard-code `D:` as the root drive, but most machines use `C:`. This change uses the same normalization function in the test assertion to ensure the drives match. ## To Do - [ ] ~~Documentation.~~ - [x] Changelog. - [x] Tests. (this is a tests change) ## What changed? * Updated tests to generate the drive name via normalization, instead of hard-coding `D:`. * Updated the `Item::destination()` method to document the `relative_to_libdir` param. ## How tested? * [x] Tests pass locally.
This commit is contained in:
parent
60f24cdc74
commit
da5ec00aaf
3 changed files with 13 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue