mirror of
https://github.com/beetbox/beets.git
synced 2025-12-24 17:43:52 +01:00
Avoid a little global state (#1330)
For even clearer interaction with the environment.
This commit is contained in:
parent
eec8d5d2be
commit
31c7c4a877
2 changed files with 3 additions and 6 deletions
|
|
@ -53,8 +53,6 @@ class PathQuery(dbcore.FieldQuery):
|
|||
escape_re = re.compile(r'[\\_%]')
|
||||
escape_char = b'\\'
|
||||
|
||||
_is_windows = platform.system() == 'Windows'
|
||||
|
||||
def __init__(self, field, pattern, fast=True, case_sensitive=None):
|
||||
"""Create a path query.
|
||||
|
||||
|
|
@ -65,7 +63,7 @@ class PathQuery(dbcore.FieldQuery):
|
|||
|
||||
# By default, the case sensitivity depends on the platform.
|
||||
if case_sensitive is None:
|
||||
case_sensitive = not self._is_windows
|
||||
case_sensitive = platform.system() != 'Windows'
|
||||
self.case_sensitive = case_sensitive
|
||||
|
||||
# Use a normalized-case pattern for case-insensitive matches.
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ from __future__ import (division, absolute_import, print_function,
|
|||
unicode_literals)
|
||||
|
||||
from functools import partial
|
||||
from mock import patch
|
||||
|
||||
from test import _common
|
||||
from test._common import unittest
|
||||
|
|
@ -476,11 +475,11 @@ class PathQueryTest(_common.LibTestCase, TestHelper, AssertsMixin):
|
|||
self.assert_items_matched(results, ['path item', 'caps path'])
|
||||
|
||||
# test platform-aware default sensitivity
|
||||
with patch('beets.library.PathQuery._is_windows', False):
|
||||
with _common.platform_posix():
|
||||
q = makeq()
|
||||
self.assertEqual(q.case_sensitive, True)
|
||||
|
||||
with patch('beets.library.PathQuery._is_windows', True):
|
||||
with _common.platform_windows():
|
||||
q = makeq()
|
||||
self.assertEqual(q.case_sensitive, False)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue