-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Rewrite and speed up query tests #5813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: move-queries-types-to-respective-modules
Are you sure you want to change the base?
Rewrite and speed up query tests #5813
Conversation
And remove `force_implicit_query_detection` attribute from `PathQuery` class.
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.
And rewrite test_query.py
Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry. |
1a1bbbc
to
f0ba201
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors test utilities and updates query abstractions to improve test performance and clarity.
- Adds a pytest hook to generate readable IDs for parametrized tests.
- Refactors the
item
fixture to accept keyword overrides via defaults. - Marks
Query
methods as abstract and adjusts their default implementations.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
File | Description |
---|---|
test/conftest.py | Import inspect and Query , add pytest_make_parametrize_id hook for clearer test IDs. |
beets/test/_common.py | Extend item() fixture to accept **kwargs and merge with defaults. |
beets/dbcore/query.py | Annotate clause and match as abstract, remove default returns, and change col_clause to raise. |
Comments suppressed due to low confidence (3)
beets/dbcore/query.py:99
- The default implementation of
clause
no longer returns(None, ())
, so it implicitly returnsNone
. Restorereturn None, ()
or explicitly raiseNotImplementedError
if there is no default behavior.
def clause(self) -> tuple[str | None, Sequence[Any]]:
beets/dbcore/query.py:105
- The abstract
match
method has no implementation or exception, so it will implicitly returnNone
. Add araise NotImplementedError
or a proper fallback implementation.
def match(self, obj: Model):
beets/dbcore/query.py:154
- Changing
col_clause
to alwaysraise NotImplementedError
removes the previous default(self.field, ())
behavior. If subclasses rely on that fallback, this will break them—either restore the default return or ensure all subclasses implement it.
def col_clause(self) -> tuple[str, Sequence[SQLiteType]]:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like some good stuff to me 👍
I appreciate the use of the parameterize fixture, the tests are way more understandable now!
You checked that we still have the same coverage?
38bd19f
to
0133f06
Compare
Previously:
Now: