-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Centralize test setup #5362
Centralize test setup #5362
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. |
604a683
to
eec8c19
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.
This is an incredibly comprehensive PR! I've left a few notes, but everything looks good. Perhaps you could use pathlib
in the functions you've rewritten, so that they don't need to be migrated later? Or we can leave that for the later pathlib
-specific PR(s).
I'll try and get my review in over the next day or two! I want to really sit down and go through it all. |
1153070
to
179d4d9
Compare
That's a very good point. I was careful to not try and refactor anything to do with paths (out of scope here, and the PR size would have quickly gotten out of hand) but I think it's a good idea to use For now I made the new methods in |
179d4d9
to
3e188d6
Compare
I agree. When we fully migrate to |
ff9f479
to
b91a7f9
Compare
I like the new uses of |
I think it would be good if I opened a pathlib PR (as I keep saying I will) after this PR is done. Like this PR, it will have a lot of small line changes that are just replacing function calls and simplifying, but this PR being merged will make that shorter and easier to parse. |
b91a7f9
to
28ae414
Compare
…orter implementations
A couple of `ConfigTest` would previously fail locally since they somehow depended on the local environment to work fine. This commmit decouples them from any environment by setting up patching of the environment variables properly.
This aids with the removal of custom import files prep implementations.
And rewrite the tests since they were far too confusing to follow.
"test" plugin was not properly cleaned up after loading and would therefore stay around and picked up by other tests.
A constant `preload_plugin` is used to disable loading the plugin in the `setUp` initialisation, allowing the plugin to be loaded manually by the tests. Also added a cleanup instruction to remove listeners from configured plugins, and removed this logic from several tests.
ee49c3b
to
edc820d
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.
Amazing work @snejus!
edc820d
to
6ed54e2
Compare
6ed54e2
to
5f395ab
Compare
I have no objections! Merge whenever you'd like @snejus |
This PR deduplicates shared tests setup that was used across test files. It attempts to centralise the setup into a single source of truth implementation in
beets.test.helper
.This works towards the eventual migration to
pytest
(#5361) making it easier to replace the tests setup withpytest
fixtures.It builds upon the temporary files cleanup in #5345.
Details
Test setup
beets.test._common.TestCase
andbeets.test.helper.TestHelper
were merged into a single implementation asbeets.test.helper.BeetsTestCase
.unittest.TestCase
andbeets.test.helper.TestHelper
combination withbeets.test.helper.ImportTestCase
test/test_plugins.py
removing duplicate import files setup.beets.test.helpers.PluginMixin
.Removals
def suite()
functions that were previously used for tests collection.setUp
andtearDown
methods from many test files given that the functions that they performed had been centralised inbeets.test.helper
.Importing
_setup_import_session
implementations inTerminalImportSessionSetup
andImportHelper
.ImportHelper._create_import_dir
andTestHelper.create_importer
implementations intoImportHelper.setup_importer
.ImportHelper.prepare_albums_for_import
andImportHelper.prepare_album_for_import
.AsIsImporterMixin
which provides a methodrun_asis_importer
to setup asis (non-autotag) importer and run it