mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
Refactor test_query
And rewrite test_query.py
This commit is contained in:
parent
2c6f314f4f
commit
09b22949c0
3 changed files with 413 additions and 818 deletions
|
|
@ -63,8 +63,8 @@ HAVE_SYMLINK = sys.platform != "win32"
|
||||||
HAVE_HARDLINK = sys.platform != "win32"
|
HAVE_HARDLINK = sys.platform != "win32"
|
||||||
|
|
||||||
|
|
||||||
def item(lib=None):
|
def item(lib=None, **kwargs):
|
||||||
i = beets.library.Item(
|
defaults = dict(
|
||||||
title="the title",
|
title="the title",
|
||||||
artist="the artist",
|
artist="the artist",
|
||||||
albumartist="the album artist",
|
albumartist="the album artist",
|
||||||
|
|
@ -99,6 +99,7 @@ def item(lib=None):
|
||||||
album_id=None,
|
album_id=None,
|
||||||
mtime=12345,
|
mtime=12345,
|
||||||
)
|
)
|
||||||
|
i = beets.library.Item(**{**defaults, **kwargs})
|
||||||
if lib:
|
if lib:
|
||||||
lib.add(i)
|
lib.add(i)
|
||||||
return i
|
return i
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
|
import inspect
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from beets.dbcore.query import Query
|
||||||
|
|
||||||
|
|
||||||
def skip_marked_items(items: list[pytest.Item], marker_name: str, reason: str):
|
def skip_marked_items(items: list[pytest.Item], marker_name: str, reason: str):
|
||||||
for item in (i for i in items if i.get_closest_marker(marker_name)):
|
for item in (i for i in items if i.get_closest_marker(marker_name)):
|
||||||
|
|
@ -21,3 +24,20 @@ def pytest_collection_modifyitems(
|
||||||
skip_marked_items(
|
skip_marked_items(
|
||||||
items, "on_lyrics_update", "No change in lyrics source code"
|
items, "on_lyrics_update", "No change in lyrics source code"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def pytest_make_parametrize_id(config, val, argname):
|
||||||
|
"""Generate readable test identifiers for pytest parametrized tests.
|
||||||
|
|
||||||
|
Provides custom string representations for:
|
||||||
|
- Query classes/instances: use class name
|
||||||
|
- Lambda functions: show abbreviated source
|
||||||
|
- Other values: use standard repr()
|
||||||
|
"""
|
||||||
|
if inspect.isclass(val) and issubclass(val, Query):
|
||||||
|
return val.__name__
|
||||||
|
|
||||||
|
if inspect.isfunction(val) and val.__name__ == "<lambda>":
|
||||||
|
return inspect.getsource(val).split("lambda")[-1][:30]
|
||||||
|
|
||||||
|
return repr(val)
|
||||||
|
|
|
||||||
1206
test/test_query.py
1206
test/test_query.py
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue