Commit Graph

62 Commits

Author SHA1 Message Date
Sebastian Mohr
c029f1f363 test_logging:LoggingLevelTest now uses pytest PluginMixin 2026-04-11 11:05:03 +02: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
Jesse Weinstein
72ce9ea3eb use underscore in name for pep-8s sake 2016-01-12 22:14:12 -08:00
Jesse Weinstein
d93f723263 Convert SKIP_SLOW_TESTS to its own decorator 2016-01-12 21:53:52 -08:00
Jesse Weinstein
760298b8e4 Mark slow tests to be skipped if SKIP_SLOW_TESTS env var is defined
Saves over 100 seconds.
2016-01-10 23:18:47 -08:00
Peter Kessen
6b408507f6 added encoding as comment in files
added line like
# -*- coding: utf-8 -*-
to all files without license
2015-11-19 18:52:57 +01:00
Peter Kessen
60e225deae corrected test for logging see #1627 2015-09-30 20:02:32 +02:00
Peter Kessen
9c34bde456 added test for logging 2015-09-27 20:16:39 +02:00
Bruno Cauet
76be623031 Fix concurrent logging testing
Set the verbosity in the config from the beginning.

Use self-made barriers (DummyPlugin.step1, DummyPlugin.step2) and
Thread.join() to ensure everything is going as expected.
2015-04-01 17:38:49 +02:00
Bruno Cauet
2c37602d66 Concurrent logging tests: raise thread exc in main thread
In ConcurrentEventsTest.test_concurrent_events listener1 sometimes has a
wrong log level. However the AssertionError is raised in a thread and
not the main one, so the test seems passing while it should fail.
By storing the exception and raising it later we solve that issue,
allowing to fix the random fail.
2015-04-01 17:06:42 +02:00
Bruno Cauet
05de43a942 Share logging level between beets base logger refs
Add BeetsLogger.set_global_level() so the 'beets' logger has the same
level in all threads, which is important for an import session.
2015-03-31 18:03:11 +02:00