Commit Graph

71 Commits

Author SHA1 Message Date
Š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
Sebastian Mohr
5369a932cf Instead of duplicating the message completely we just add a record for
the prefix which we can than use in the formatter.
2026-06-20 13:28:47 +02:00
Sebastian Mohr
ed13ceee14 Removed dummy: prefix from logging tests. 2026-06-20 13:28:47 +02:00
Sebastian Mohr
5bb4a298b4 Added tests for LegacyFormatter 2026-06-20 13:28:47 +02:00
Sebastian Mohr
1fe0e34201 Removed capture_log 🎉 2026-06-16 17:14:03 +02:00
Sebastian Mohr
922b568bd8 Replaced instances of capture_log with caplog 2026-06-16 17:14:03 +02:00
Sebastian Mohr
93a53edf01 Use monkeypatch in logging instead of patch 2026-06-11 10:39:14 +02:00
Sebastian Mohr
6327f1122a Remove now unused ImportTestCase 2026-06-11 10:39:14 +02:00
Sebastian Mohr
b745157bec test_logging: ImportTestCase -> ImporterHelper 2026-06-11 10:39:14 +02:00
Šarūnas Nejus
ccdccdfa8d Remove slow_test unittest marker 2026-04-22 21:47:16 +01:00
Anton Bobov
67e668d81f fix: Sanitize log messages by removing control characters
Added regex pattern to strip C0/C1 control characters (excluding useful
whitespace) from log messages before terminal output. This prevents
disruptive/malicious control sequences from affecting terminal
rendering.
2025-12-02 15:27:24 +05:00
Sebastian Mohr
89c2e10680 Removed typealias, worked locally with mypy but does seem to cause
issues with the ci. Also python 3.9 requires unions here...
2025-09-30 13:39:49 +02:00
Sebastian Mohr
caebf185f1 Removed unused ParamSpec and added a consistency check in the tests. 2025-09-30 13:37:51 +02:00
Sebastian Mohr
461bc049a0 Enhanced custom logger typing and logging tests 2025-09-30 13:37:51 +02:00
Šarūnas Nejus
7954671c73 Mock DummyPlugin properly 2025-09-29 11:39:16 +01:00
Šarūnas Nejus
d6b6ac3387 Replace logging f-strings with arguments 2025-08-30 23:10:21 +01:00
Šarūnas Nejus
d93ddf8dd4 Do not use explicit indices for logging args when not needed 2025-08-30 23:10:21 +01:00
Šarūnas Nejus
1c16b2b308 Replace string concatenation (' + ')
- Join hardcoded strings
- Replace concatenated variables with f-strings
2025-08-30 23:10:15 +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
f36bc497c8 Fix lint issues
- Fix imports
- Fix pytest issues
- Do not assign lambda as variable
- Use isinstance instead of type to check type
- Rename ambiguously named variables
- Name custom errors with Error suffix
2024-09-21 11:59:18 +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
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
cb82917fe0 Replace assertFalse 2024-08-12 08:43:41 +01:00
Šarūnas Nejus
0ecc345143 Replace assertTrue 2024-08-05 17:11:16 +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
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
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
2d5fd907c3 Remove redundant setup_beets and teardown_beets instructions 2024-07-28 18:58:34 +01:00
Šarūnas Nejus
6c1e26acc9 Replace unittest.TestCase, TestHelper by BeetsTestCase 2024-07-28 18:58:34 +01:00
Šarūnas Nejus
3e278159ed Dedupe TestHelper and _common.TestCase setup 2024-07-28 18:58:33 +01: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
c272696d9f test_logging: fix incorrect exception handling
Another incorrect py2 -> py3 translation. Since python 3 attached the
traceback to the exception, this should preserve the traceback without
needing to resort to sys.exc_info
2022-01-20 21:16:17 +01:00
wisp3rwind
807f124ef8 really remove all six imports
apparently, pyupgrade didn't know how to handle these...
2022-01-20 00:26:01 +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
Jack Wilsdon
f622e42a88 Replace blind excepts with generic Exception excepts in tests 2017-04-29 00:12:14 +02: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
36ed75cd01 use reraise from six 2016-06-24 05:53:55 -04:00
Johnny Robeson
5f4678e3e8 use StringIO from six 2016-06-23 04:40:18 -04:00
Adrian Sampson
71b9fd785c Revert "Do __name__ comparison with bytes and not unicode"
This reverts commit 9c41c39913.
That commit used byte strings for the `if __name__ == '__main__'` pattern,
which was necessary when we were doing unicode_literals. But it is wrong on
Python 3, and now that we're liberated from unicode_literals, we need to go
back to native strings for this comparison.
2016-05-29 19:19:59 -07: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
955eae46c6 Removed unicode_literals from test_logging 2016-02-23 18:27:30 +01:00