Commit Graph
64 Commits
Author SHA1 Message Date
Šarūnas Nejus 97904e7e16 Refactor autotag to use Source abstraction
Introduce Source class to encapsulate metadata extraction logic,
replacing scattered `get_most_common_tags` calls throughout codebase.

- Add Source class in importer.tasks with artist, name, and metadata
- Simplify `distance()` to accept Source.data instead of items list
- Update display functions to use Source objects
- Cache Source creation with @cached_property on ImportTask

This centralizes metadata handling and reduces coupling between
autotag and library modules.
2026-08-05 02:06:48 +01:00
Mohsin Hirani 8e6be08849 style: apply ruff formatting to test_util.py 2026-08-02 13:50:06 -04:00
Mohsin Hirani 46498a8967 docs: fix RST markup and improve test coverage per review 2026-08-02 13:39:12 -04:00
Mohsin Hirani 4cf62d5360 test: add tests for editor_command() config option 2026-08-02 13:38:36 -04:00
Šarūnas Nejus 951e32a852 Use pathlib.Path wherever possible in tests 2026-07-30 12:18:49 +01:00
Qalipso a8439e2d07 Fix unique_path counter for names ending in two or more digits
unique_path parses a trailing counter so it can continue from it, but the
pattern is `\.(\d)+$` -- a single-digit group repeated, not a multi-digit
group. group(1) is therefore the last digit only, and the counter restarts
from it:

    track.10.mp3 -> track.1.mp3   (expected track.11.mp3)
    track.12.mp3 -> track.3.mp3
    track.123.mp3 -> track.4.mp3

The returned path still does not exist, so nothing is overwritten, but the
new name sorts before the file it was derived from, and the scan restarts
from a low number when the neighbours are already taken.

Use `\.(\d+)$`. Existing coverage only exercised a single-digit counter
(`x.1.mp3`), which is why this held.
2026-07-30 12:52:03 +02:00
Šarūnas Nejus d24c0d341e Rename PathsMixin.temp_dir_path to PathsMixin.temp_path for consistency 2026-07-21 11:15:25 +01:00
Šarūnas Nejus 2e9ace7b20 Replace PathsMixin.temp_dir attribute with PathsMixin.temp_dir_path 2026-07-21 11:15:25 +01:00
Šarūnas Nejus 230bf19c7f Remove redundant test logic exposed by full coverage
- Removing the coverage omit configuration exposed unused branches, helpers, and
  fixtures across the test suite.
- Delete that redundant logic and simplify affected tests while preserving their
  behavior.
2026-07-07 15:57:35 +01:00
Šarūnas Nejus 8968648341 Update asciification tests 2026-07-03 18:59:19 +01:00
Šarūnas Nejus 89a831613a Centralize path asciification normalization
- Move Unicode normalization and separator replacement into util.asciify_path.
- Update library callers and relocate focused asciify tests to util coverage.
2026-07-03 18:59:19 +01:00
Šarūnas Nejus b1ae461723 Rip out util tests from test_files 2026-06-30 21:39:34 +01:00
Sebastian Mohr 54a2bd20e1 Removed This file is part of beets... headers. 2026-06-29 11:20:15 +02:00
Sebastian Mohr adfb73b66d Run ruff format 2026-05-20 16:53:06 +02:00
Aditya Inamdar 886bb8626d Remove implementation-focused tests per review 2026-03-16 21:19:12 +00:00
Aditya Inamdar 518a4a83fa Fix Windows fallback for config editor command 2026-03-16 21:19:12 +00:00
Šarūnas Nejus 01b6ea7898 Simplify and speed up plurality/album tags retrieval tests 2025-05-31 19:17:42 +01:00
Šarūnas Nejus 1c9aebd36c match.current_metadata -> util.get_most_common_tags 2025-05-31 17:58:23 +01:00
Šarūnas Nejus c9f98fca55 Use unittest.TestCase for tests that don't require the dir setup 2025-05-26 12:40:38 +01:00
Šarūnas Nejus de09c3217a Do not 'legalize' paths by removing everything following a dot
TIL that `with_suffix` does not simply append the suffix to the filename
- it instead replaces the old/current suffix. Or whatever seems to
look like a suffix, in our case, unfortunately...
2025-05-12 09:14:24 +01:00
Šarūnas Nejus 921b7ed9ea Rewrite legalisation tests for readability 2025-05-04 12:23:26 +01:00
Šarūnas Nejus 6a7832f207 Adjust tests to work in Windows 2025-05-04 12:23:26 +01:00
Šarūnas Nejus 5826d6b59b Remove handling of mbcs encoding
This has been phased out in Python 3.6.

https://peps.python.org/pep-0529/
2025-05-04 12:23:26 +01:00
Šarūnas Nejus 4fcb148d60 Add test for legalization logic 2025-05-04 12:23:26 +01:00
Šarūnas Nejus 40fbc8ee7e Fix and simplify path truncation 2025-05-04 12:23:26 +01:00
Šarūnas Nejus 9acfa3c175 Remove arg_encoding 2025-04-21 12:41:57 +01:00
Šarūnas Nejus 85a17ee503 Reformat the codebase 2024-09-21 11:57:48 +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 0ecc345143 Replace assertTrue 2024-08-05 17:11:16 +01:00
Šarūnas Nejus fcff5d72af Remove def suite TestLoader definitions 2024-07-28 18:58:51 +01:00
Šarūnas Nejus 3e278159ed Dedupe TestHelper and _common.TestCase setup 2024-07-28 18:58:33 +01:00
Arav K. 95dc07a404 Remove the 'confit' backport
The commit to deprecate 'confit' was made on June 1, 2019.  It's been 5
years!  It is now removed entirely.

See Also: e2d7780f97
2024-06-26 02:04:14 +02:00
freddiewanah e0de6e1b89 refactor the test methods to avoid suboptimal asserts. 2024-04-08 21:39:25 +08:00
Lars Kruse 508d28f66b tests: move reusable test-related modules into the beets package
External Python packages interfacing beets may want to use an in-memory
beets library instance for testing beets-related code.
The `TestHelper` class is very helpful for this purpose.
Previously `TestHelper` was located in the `test/` directory.
Now it is part of `beets` itself (`beets.test.helper.TestHelper`) and
can be easily imported.
2024-01-15 19:40:57 +01:00
Serene-Arc a6e5201ff3 Apply formatting tools to all files
This is 'the big one', which touches every file so that it all conforms
to the given standard.
2023-10-22 09:53:18 +10:00
wisp3rwind a6d74686d8 test: separate case_sensitive unit tests from PathQueryTest
- move tests for case_sensitive to test_util.py, since this is not
  really the concern of PathQueryTest
- removes part of the tests, since the tests that patch os.path.samefile
  and os.path.exists are super brittle since they test the
  implementation rather than the functionality of case_sensitive().
  This is a prepartory step for actually changing the implementation,
  which would otherwise break the tests in a confusing way...
2022-12-24 13:36:53 +01:00
Adrian Sampson 8baf3e302d Skip an unhelpful test on Windows
On Windows, converting command-line arguments (hopefully!!!) only needs
to deal with valid strings from the OS. So it is not really relevant to
test with non-UTF-8, non-surrogate bytes.
2022-10-01 17:13:57 -07:00
wisp3rwind cc8c3529fb confit: Improve deprecation warning
Show the actual origin of the import statement, cf. #4024
2022-02-01 19:10:24 +01:00
Andrew Rogl ee4268dabb Remove unused imports
Fix imports
Fix formatting
2021-08-26 20:59:48 +10:00
Andrew Rogl 1ec87a3bdd pyupgrade beetsplug and tests
All tests working
More tidy up to be done
2021-08-26 19:12:51 +10:00
Adrian Sampson 75c41c0546 Remove most six.PY2 checks 2021-08-19 16:45:11 -04:00
Adrian Sampson a88682e7bb Undo from _common import unittest indirection
This was a vestige from when we used to need the unittest2 library for pre-2.7
compatibility. Now that we require Python 2.7, we aren't using that library
and this indirection wasn't doing any good.
2016-11-26 18:46:44 -05:00
Johnny Robeson 7a2bdf502f s/utf8/utf-8/ in all encoding/decoding contexts
This matches up with the python documentation.
2016-09-06 23:10:24 -04:00
Johnny Robeson c26266cab0 convert byte args to string on PY3 in command_output
The strings are surrogateescaped to make sure we can get the bytes
representation back
2016-08-11 21:58:58 -04:00
Johnny Robeson e8afcbe7ec replace unicode with six.text_type 2016-06-24 05:53:49 -04:00
Johnny Robeson c52394c499 fix the rest of b'__main__': 2016-05-30 01:11:37 -04:00
Adrian Sampson e54c7eec3d Standardize __future__ imports without parentheses
Since the list is short enough now, we don't need parentheses for the line
wrap. This is a little less ugly.
2016-02-28 15:03:51 -08:00
Peter Kessen ccc61a638e Removed unicode_literals from test_util 2016-02-25 07:53:20 +01:00