Commit graph

12502 commits

Author SHA1 Message Date
Šarūnas Nejus
5b5c564a69
autobpm: Add a new beat_track_kwargs configuration option to autobpm 2024-08-19 22:44:16 +01:00
Šarūnas Nejus
49cae5ca23
autobpm: Fix the issue with tempo being a numpy array 2024-08-19 22:44:16 +01:00
Šarūnas Nejus
03cf567a90
autobpm: Add autobpm extra and update the docs
Given that librosa has been introducing breaking changes like there's no
tomorrow, use '^' version specifier to only allow updating the patch
version.
2024-08-19 22:44:16 +01:00
Šarūnas Nejus
38a26af149
Replace unittest assert methods by assert statement (#5386)
... continuing the test suite migration to `pytest` (#5361), this PR
replaces `unittest` method assertions with `assert` statement.

See the table below for a list of the replaced methods and their counts.
This should help clarify the size of the pull request 😆.

To keep things simple for the review, I have replaced each method in its
own commit. This
way, things should be easy to follow if you step through the commits one
by one. 🙂

method                   | count
---                      | ---
**`assertEqual`**        | 1747
**`assertIn`**           | 200
**`assertTrue`**         | 149
**`assertIsNone`**       | 87
**`assertFalse`**        | 85
**`assertRaises`**       | 69
**`assertNotIn`**        | 64
**`assertNotEqual`**     | 39
**`assertIsNotNone`**    | 35
**`assertIsInstance`**   | 35
**`assertLessEqual`**    | 23
**`assertGreater`**      | 15
**`assertLess`**         | 14
**`assertGreaterEqual`** | 14
**`assertAlmostEqual`**  | 9
**`assertRaisesRegex`**  | 4
**`assertCountEqual`**   | 2
**`assertListEqual`**    | 1


 Note that this *only* replaces methods provided by
`unittest` by default.
**Custom** assertion method replacements (like `assertExists` will be
addressed in a separate PR).
2024-08-19 08:08:16 +01:00
Šarūnas Nejus
4b69b493d2
Use f-string syntax 2024-08-16 17:47:23 +01:00
Šarūnas Nejus
093949bf2b
Fixup: use fast queries for fields shared between albums and items tables (#5385)
I surprisingly found that many queries for fields that exist in the
database are 'slow'. Querying items with `month:0` used a slow query
while `title:0` used a fast one.

I found the mistake in the logic: the field existence in the db check
was done *after* prepending the table name to the field. This meant that
the logic wrongly checked e.g. `items.field` instead of `field`.

This commit fixes the above and renames the variables for more clarity.
2024-08-12 09:59:38 +01:00
Šarūnas Nejus
090b62f5b0
Make this test ignore my local beets config 2024-08-12 08:49:30 +01:00
Šarūnas Nejus
d3bdd93bf6
Replace assertAlmostEqual 2024-08-12 08:49:30 +01:00
Šarūnas Nejus
fcc4d8481d
Replace assertListEqual 2024-08-12 08:43:43 +01:00
Šarūnas Nejus
fdb8c28271
Replace assertCountEqual 2024-08-12 08:43:43 +01:00
Šarūnas Nejus
46bdb84b46
Replace assertGreater and assertGreaterEqual 2024-08-12 08:43:43 +01:00
Šarūnas Nejus
6a3380bcb5
Replace assertLess and assertLessEqual 2024-08-12 08:43:43 +01:00
Šarūnas Nejus
eda0ef11d6
Replace assertIsInstance 2024-08-12 08:43:42 +01:00
Šarūnas Nejus
f9359df0d1
Replace assertNotEqual 2024-08-12 08:43:42 +01:00
Šarūnas Nejus
847e3858a6
Replace assertRaises 2024-08-12 08:43:42 +01:00
Šarūnas Nejus
9a05d27acf
Replace assertEqual 2024-08-12 08:43:42 +01:00
Šarūnas Nejus
6631b6aef6
Replace assertNotIn 2024-08-12 08:43:42 +01:00
Šarūnas Nejus
11e948121c
Replace assertIn 2024-08-12 08:43:42 +01:00
Šarūnas Nejus
2616bcc950
Replace assertIsNotNone 2024-08-12 08:43:41 +01:00
Šarūnas Nejus
5d4911e905
Replace assertIsNone 2024-08-12 08:43:41 +01:00
Šarūnas Nejus
cb82917fe0
Replace assertFalse 2024-08-12 08:43:41 +01:00
Šarūnas Nejus
c216b636ac
Fixup: make common fields use fast queries
I surprisingly found that many queries for fields that exist in the
database are 'slow'. Querying items with 'month:0' used a slow query
while 'title:0' used a fast one.

I found the mistake in the logic: the field existence in the db check
was done *after* prepending the table name to the field. This meant that
the logic wrongly checked e.g. 'items.field' instead of 'field'.

This commit fixes the above and renames the variables for more clarity.
2024-08-11 21:35:28 +01:00
Šarūnas Nejus
0ecc345143
Replace assertTrue 2024-08-05 17:11:16 +01:00
Šarūnas Nejus
7703c9e338
Remove redundant unicode decoding (#5379)
These days musicbrainz returns unicode strings as expected.
2024-08-04 20:09:16 +01:00
Šarūnas Nejus
f006476dcf
Remove redundant unicode decode
These days musicbrainz returns unicode strings as expected.
2024-08-04 15:03:53 +01:00
Serene
8f44568ddd
Add @bal-e to docs/team.rst (#5374)
Thanks for adding me as a contributor, @snejus!
2024-08-02 09:31:19 +10:00
Arav K.
657fffd5b7 [docs/team] Add '@bal-e' 2024-07-31 23:24:18 +02:00
Šarūnas Nejus
c05b3cff82
Centralize test setup (#5362)
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 with `pytest` fixtures.

It builds upon the temporary files cleanup in #5345.

## Details

### Test setup

* Mostly duplicate test setup implementations in
`beets.test._common.TestCase` and `beets.test.helper.TestHelper` were
merged into a single implementation as
`beets.test.helper.BeetsTestCase`.
* Replaced `unittest.TestCase` and `beets.test.helper.TestHelper`
combination with `beets.test.helper.ImportTestCase`
* Refactored `test/test_plugins.py` removing duplicate import files
setup.
* Centralised setting up the database on disk.
* Centralised plugin test setup into `beets.test.helpers.PluginMixin`.

### Removals

* Around 1/3 of the removed lines correspond to the removal of `def
suite()` functions that were previously used for tests collection.
* Removed redundant `setUp` and `tearDown` methods from many test files
given that the functions that they performed had been centralised in
`beets.test.helper`.
* Removed redundant library initialisations


### Importing

* Centralised import directory creation (only gets created on the first
access).
* Deduplicated `_setup_import_session` implementations in
`TerminalImportSessionSetup` and `ImportHelper`.
* Merged `ImportHelper._create_import_dir` and
`TestHelper.create_importer` implementations into
`ImportHelper.setup_importer`.
* Merged various takes on import files prep into
`ImportHelper.prepare_albums_for_import` and
`ImportHelper.prepare_album_for_import`.
* Seeing that many tests used it, defined `AsIsImporterMixin` which
provides a method `run_asis_importer` to setup _asis_ (non-autotag)
importer and run it
2024-07-31 08:53:33 +01:00
Šarūnas Nejus
5f395ab4f4
Configure plugins using PluginMixin.configure_plugin 2024-07-29 15:33:12 +01:00
Šarūnas Nejus
199f3079f2
Use PluginMixin in tests that load plugins manually
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.
2024-07-28 18:58:54 +01:00
Šarūnas Nejus
9c75513686
test_ui: Fix Config/Plugin/Completion tests interdependency
"test" plugin was not properly cleaned up after loading and would
therefore stay around and picked up by other tests.
2024-07-28 18:58:54 +01:00
Šarūnas Nejus
e097f1a8c6
Rewrite FileFilterPluginTest
And rewrite the tests since they were far too confusing to follow.
2024-07-28 18:58:54 +01:00
Šarūnas Nejus
6dda984862
Standardize ImportPretendTest import files prep 2024-07-28 18:58:54 +01:00
Šarūnas Nejus
01c24bb3a7
Return paths from import files prep
This aids with the removal of custom import files prep implementations.
2024-07-28 18:58:54 +01:00
Šarūnas Nejus
139b54ebd1
Add setup_singleton_importer for singleton importer 2024-07-28 18:58:53 +01:00
Šarūnas Nejus
92f79dbfb9
Fix ConfigTest failures locally
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.
2024-07-28 18:58:53 +01:00
Šarūnas Nejus
8d85cfd72a
Define AsIsImporterMixin to run autotag=False importer 2024-07-28 18:58:53 +01:00
Šarūnas Nejus
f042f5ad32
Leave a single source of truth for importer setup 2024-07-28 18:58:53 +01:00
Šarūnas Nejus
8065ff0461
Split album and singleton tests in edit and filefilter 2024-07-28 18:58:53 +01:00
Šarūnas Nejus
7e444db914
Rename _create_import_dir -> prepare_album_for_import 2024-07-28 18:58:53 +01:00
Šarūnas Nejus
c2fdf9873d
Synchronise ImportHelper._create_import_dir and TestHelper.create_importer implementations 2024-07-28 18:58:53 +01:00
Šarūnas Nejus
41bbb77a0b
Centralise 'import_dir' creation 2024-07-28 18:58:53 +01:00
Šarūnas Nejus
1f8466f04a
Move create_importer to ImportHelper 2024-07-28 18:58:53 +01:00
Šarūnas Nejus
fcff5d72af
Remove def suite TestLoader definitions 2024-07-28 18:58:51 +01:00
Šarūnas Nejus
432da560e4
Create PluginTestCase to dedupe plugin setup 2024-07-28 18:58:35 +01:00
Šarūnas Nejus
16cf8dd937
Centralize db setup on disk 2024-07-28 18:58:34 +01:00
Šarūnas Nejus
7d7f16395c
Remove redundant library setUp instructions 2024-07-28 18:58:34 +01:00
Šarūnas Nejus
2d5fd907c3
Remove redundant setup_beets and teardown_beets instructions 2024-07-28 18:58:34 +01:00
Šarūnas Nejus
b64eaeda0a
Rename LibTestCase to ItemInDBTestCase 2024-07-28 18:58:34 +01:00
Šarūnas Nejus
91099d362e
Deduplicate TerminalImportHelper and rename to TerminalImportMixin 2024-07-28 18:58:34 +01:00