tests: refactor test_sort.py#6718
Open
snejus wants to merge 10 commits into
Open
Conversation
|
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. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## migrate-helper-test-classes #6718 +/- ##
===============================================================
- Coverage 74.72% 74.51% -0.22%
===============================================================
Files 162 162
Lines 20820 20820
Branches 3298 3298
===============================================================
- Hits 15558 15514 -44
- Misses 4505 4549 +44
Partials 757 757 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
grug see PR want make test/dbcore/test_sort.py smaller and less copy-paste. grug like less duplicate, but grug see some new tests now depend on tie order / same-path tricks, so test may go flaky and maybe break on windows.
Changes:
- replace many small test classes with a few parametrized pytest tests
- move library setup into class-scoped fixtures via
TestHelper - move sort coverage to query-string form (ex:
"year+") instead of many sort object combos
c0ff2bb to
1080ae6
Compare
Comment on lines
+160
to
+167
| def test_config_overrides(self, config): | ||
| config.set({"sort_item": "artist-", "sort_album": "albumartist-"}) | ||
|
|
||
| def test_fixed_field_case_insensitive(self): | ||
| config["sort_case_insensitive"] = True | ||
| q = "album+" | ||
| results = list(self.lib.albums(q)) | ||
| assert results[0].album == "album" | ||
| assert results[1].album == "Album A" | ||
| artists = [r.artist for r in self.lib.items()] | ||
| albumartists = [r.albumartist for r in self.lib.albums()] | ||
|
|
||
| def test_fixed_field_case_sensitive(self): | ||
| config["sort_case_insensitive"] = False | ||
| q = "album+" | ||
| results = list(self.lib.albums(q)) | ||
| assert results[0].album == "Album A" | ||
| assert results[-1].album == "album" | ||
| assert artists == ["Two", "Three", "Three", "One"] | ||
| assert albumartists == ["Foo", "Baz", "Bar"] |
f38bad8 to
b6610ac
Compare
1080ae6 to
4fe22c5
Compare
b6610ac to
8e7195c
Compare
4fe22c5 to
52a1b78
Compare
8e7195c to
9080832
Compare
- Consolidate duplicate ascending sort tests across item and album fixed and flexible fields.
- Replace duplicate direct MultipleSort checks with parametrized query-string cases covering single-field, multi-field, fixed, flex, and computed sort behavior. - Reduce test repetition while keeping the same sort behavior coverage.
- Consolidate duplicate sort test coverage with parametrized cases. - Keep missing-field and mixed-presence behavior covered while reducing repeated assertions.
- Combine default and override sort assertions for items and albums. - Use the config fixture and exact ordered results to avoid global config state.
9080832 to
2ad2368
Compare
52a1b78 to
e003c31
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Consolidates
test/dbcore/test_sort.pyaround a smaller set of parameterized pytest cases instead of many near-duplicate test branches.Simplifies the test architecture by:
Tightens config-related tests to use the
configfixture, which keeps sort override assertions local to each test and avoids leaking global config state.Reduces duplicate edge-case coverage for missing fields and mixed field presence by keeping one clear representative path for each behavior.
High-level impact: