Skip to content

Commit dfa97a9

Browse files
committed
Skip tests that fail due to Windows path handling
1 parent c288300 commit dfa97a9

3 files changed

Lines changed: 28 additions & 8 deletions

File tree

beets/test/_common.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
if TYPE_CHECKING:
2020
import pytest
2121

22+
# Because the absolute path begins with something like C:, we
23+
# can't disambiguate it from an ordinary query.
24+
WIN32_NO_IMPLICIT_PATHS = "Implicit paths are not supported on Windows"
25+
2226
beetsplug.__path__ = [
2327
os.path.abspath(
2428
os.path.join(

test/dbcore/test_query.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@
3131
from beets.library import Item
3232
from beets.test import _common
3333

34-
# Because the absolute path begins with something like C:, we
35-
# can't disambiguate it from an ordinary query.
36-
WIN32_NO_IMPLICIT_PATHS = "Implicit paths are not supported on Windows"
37-
3834
_p = pytest.param
3935

4036

@@ -378,7 +374,9 @@ def test_relative(self, lib, helper):
378374

379375
assert {i.title for i in lib.items(q)} == {"relative item"}
380376

381-
@pytest.mark.skipif(sys.platform == "win32", reason=WIN32_NO_IMPLICIT_PATHS)
377+
@pytest.mark.skipif(
378+
sys.platform == "win32", reason=_common.WIN32_NO_IMPLICIT_PATHS
379+
)
382380
@pytest.mark.parametrize(
383381
"q, expected_titles",
384382
[
@@ -416,7 +414,9 @@ def test_case_sensitivity(
416414

417415
# FIXME: Also create a variant of this test for windows, which tests
418416
# both os.sep and os.altsep
419-
@pytest.mark.skipif(sys.platform == "win32", reason=WIN32_NO_IMPLICIT_PATHS)
417+
@pytest.mark.skipif(
418+
sys.platform == "win32", reason=_common.WIN32_NO_IMPLICIT_PATHS
419+
)
420420
@pytest.mark.parametrize(
421421
"q, is_path_query",
422422
[

test/dbcore/test_queryparse.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
"""Tests for dbcore query parsing helpers."""
22

3+
import sys
4+
35
import pytest
46

57
from beets.dbcore import ModelQuery, query, sort
68
from beets.dbcore.queryparse import QueryTerm
9+
from beets.test._common import WIN32_NO_IMPLICIT_PATHS
710
from beets.test.fixtures import ModelFixture1, SortFixture
811

912
_p = pytest.param
@@ -26,12 +29,25 @@ class TestQueryTermParsing:
2629
("test:", ("test", "", query.SubstringQuery)),
2730
(r":regexp", (None, "regexp", query.RegexpQuery)),
2831
(r"test::regexp", ("test", "regexp", query.RegexpQuery)),
29-
(r"test\:val", (None, "test:val", query.SubstringQuery)),
32+
_p(
33+
r"test\:val",
34+
(None, "test:val", query.SubstringQuery),
35+
marks=pytest.mark.skipif(
36+
sys.platform == "win32",
37+
reason="Backslash is parsed as a path separator in Windows",
38+
),
39+
),
3040
(r":test\:regexp", (None, "test:regexp", query.RegexpQuery)),
3141
("year:1999", ("year", "1999", query.NumericQuery)),
3242
("year:1999..2010", ("year", "1999..2010", query.NumericQuery)),
3343
("", (None, "", query.SubstringQuery)),
34-
("/tmp", ("path", "/tmp", query.PathQuery)),
44+
_p(
45+
"/tmp",
46+
("path", "/tmp", query.PathQuery),
47+
marks=pytest.mark.skipif(
48+
sys.platform == "win32", reason=WIN32_NO_IMPLICIT_PATHS
49+
),
50+
),
3551
],
3652
)
3753
def test_query_term_parsing(self, query_string, expected):

0 commit comments

Comments
 (0)