Skip to content

Commit 49f6be1

Browse files
committed
Remove case_sensitive from PathQuery.__init__
The case_sensitive parameter was only used in tests, which now use monkeypatch to control the behavior of util.case_sensitive() instead. This simplifies the PathQuery initialization logic while maintaining test coverage.
1 parent e8ba36c commit 49f6be1

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

beets/dbcore/query.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ class PathQuery(FieldQuery[bytes]):
284284
# For tests
285285
force_implicit_query_detection = False
286286

287-
def __init__(self, field, pattern, fast=True, case_sensitive=None):
287+
def __init__(self, field, pattern, fast=True):
288288
"""Create a path query.
289289
290290
`pattern` must be a path, either to a file or a directory.
@@ -296,14 +296,11 @@ def __init__(self, field, pattern, fast=True, case_sensitive=None):
296296

297297
path = util.normpath(pattern)
298298

299-
# By default, the case sensitivity depends on the filesystem
300-
# that the query path is located on.
301-
if case_sensitive is None:
302-
case_sensitive = util.case_sensitive(path)
303-
self.case_sensitive = case_sensitive
299+
# Case sensitivity depends on the filesystem that the query path is located on.
300+
self.case_sensitive = util.case_sensitive(path)
304301

305302
# Use a normalized-case pattern for case-insensitive matches.
306-
if not case_sensitive:
303+
if not self.case_sensitive:
307304
# We need to lowercase the entire path, not just the pattern.
308305
# In particular, on Windows, the drive letter is otherwise not
309306
# lowercased.

test/test_query.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,9 @@ def lib(self, helper):
903903
_p("path:/c/\\\\x", ["with backslash"], id="backslash-escaped"),
904904
],
905905
)
906-
def test_explicit(self, lib, q, expected_titles):
906+
def test_explicit(self, monkeypatch, lib, q, expected_titles):
907+
monkeypatch.setattr("beets.util.case_sensitive", lambda *_: True)
908+
907909
assert {i.title for i in lib.items(q)} == set(expected_titles)
908910

909911
@pytest.mark.skipif(sys.platform == "win32", reason=WIN32_NO_IMPLICIT_PATHS)

0 commit comments

Comments
 (0)