-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Speed up a couple of tests #5799
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
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. |
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 aims to speed up tests by switching several test classes from using BeetsTestCase to the lighter weight unittest.TestCase in cases where the filesystem setup/teardown is unnecessary.
- Remove unnecessary BeetsTestCase imports from multiple test files
- Update test class inheritance to use unittest.TestCase
- Adjust test configuration in pyproject.toml for coverage collection
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
test/test_util.py | Replaced BeetsTestCase with unittest.TestCase for utility tests |
test/test_ui.py | Updated test classes to inherit from unittest.TestCase |
test/test_sort.py | Changed CaseSensitivityTest to inherit from DummyDataTestCase and unittest.TestCase |
test/test_query.py | Replaced BeetsTestCase with unittest.TestCase in query-related tests |
test/test_logging.py | Modified LoggingTest to inherit from unittest.TestCase, removing extra BeetsTestCase import |
test/test_importer.py | Updated test classes to use unittest.TestCase |
test/test_files.py | Changed HelperTest to use unittest.TestCase |
test/plugins/* | Updated various plugin tests to replace BeetsTestCase with unittest.TestCase |
pyproject.toml | Adjusted the coverage flags configuration |
Comments suppressed due to low confidence (2)
pyproject.toml:223
- Verify that the removal of duplicate coverage flags (for both beets and beetsplug) is intentional and that the current setup still collects coverage for all required modules.
---cov=beets
test/test_sort.py:383
- Double-check that combining DummyDataTestCase with unittest.TestCase provides all necessary initialization, since the removal of BeetsTestCase might remove expected setup steps.
class CaseSensitivityTest(DummyDataTestCase, unittest.TestCase):
94d60b7
to
6fa0676
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.
That is a nice find!
Just out of interest, do you have any simple benchmarks with before and after timings?
Of course! Using $ git checkout speed-up-some-tests
$ classes=($(git diff master.. -U0 | grep -E '[A-Za-z]+Test\b' -o | sort -u))
$ poe test -k ${(j: or :)classes} | grep -e Poe -e passed
$ Poe => pytest -p no:cov -k 'ArtistFlatteningTest or BeatportResponseEmptyTest or CaseSensitivityTest or CommonOptionsParserTest or DeprecatedConfigTest or EncodingTest or EnforceRatioConfigTest or HelperTest or InferAlbumDataTest or LastGenrePluginTest or LoggingTest or MatchTest or NotQueryMatchTest or PathConversionTest or PathFormatTest or SubsonicPluginTest or SummarizeItemsTest or TagLogTest or ThePluginTest'
==== 102 passed, 1860 deselected in 18.56s ====
$ git checkout master
$ poe test -k ${(j: or :)classes} | grep -e Poe -e passed
$ Poe => pytest -p no:cov -k 'ArtistFlatteningTest or BeatportResponseEmptyTest or CaseSensitivityTest or CommonOptionsParserTest or DeprecatedConfigTest or EncodingTest or EnforceRatioConfigTest or HelperTest or InferAlbumDataTest or LastGenrePluginTest or LoggingTest or MatchTest or NotQueryMatchTest or PathConversionTest or PathFormatTest or SubsonicPluginTest or SummarizeItemsTest or TagLogTest or ThePluginTest'
==== 102 passed, 1860 deselected in 22.96s ==== Not a huge difference, actually, since this only affects 102 tests. Just had a look at specific test durations: this branch
|
6fa0676
to
5900282
Compare
Lastgenre tests do depend on the configuration made available by |
Speed up tests by using
unittest.TestCase
for tests that don't require directory setupThis PR improves test performance by switching several test classes from
BeetsTestCase
to standardunittest.TestCase
when they don't require the directory setup and teardown overhead. The changes focus on test classes that:The PR removes unnecessary imports of
BeetsTestCase
and adds direct imports ofunittest
where needed. This change reduces the test execution time by avoiding the expensive setup/teardown steps for tests that don't require them.