Commit graph

39 commits

Author SHA1 Message Date
Š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
Bruno Cauet
199844671e Add concurrent logging tests
Should work for PR #1366 as well.
2015-03-25 12:57:26 +01:00
Bruno Cauet
dfa18b1119 Make beets loggers level thread local.
This updates the beets logger class. Tests are missing.
2015-03-25 12:55:40 +01:00
Bruno Cauet
998d04d3eb Update logging tests (taken from sampsyo/thread-safe-logging) 2015-03-25 12:55:37 +01:00
Bruno Cauet
f1e13cf886 Offer verbose and very verbose modes
'verbose' is now an int and not a boolean. '-v' is level 1, '-vv' level
2. In the configuration it can be set with 'verbose: 1' or 'verbose: 2'.

Improve #1244: auditing current log levels of plugins remains.
2015-02-10 17:13:15 +01:00
Bruno Cauet
4578c4f0e1 Improve logging management for plugins
Listeners get logging level modulations, like import_stages already did.

Add extensive tests:
- explicit plugin commands are logged like core beets (INFO or DEBUG)
- import stages are more silent
- event listeners are like import stages

Delete @BeetsPlugin.listen decorator since listeners need plugin instance
context to set its logging level.

Improve #1244. Next is multiple verbosity levels.
2015-02-10 15:30:15 +01:00
Bruno Cauet
9c41c39913 Do __name__ comparison with bytes and not unicode 2015-01-20 12:03:57 +01:00
Bruno Cauet
2dab8e5fd6 Import unicode_literals in beets package 2015-01-19 21:41:33 +01:00
Bruno Cauet
90b388b775 Use __future__ imports but unicode_literals everywhere
Include import of __future__ features division, absolute_imports and
print_function everywhere. Don't add unicode_literals yet for it is
harder to convert.

Goal is smoothing the transition to python 3.
2015-01-19 12:25:16 +01:00
Bruno Cauet
2902cda036 tests: use absolute imports everywhere 2015-01-19 12:25:15 +01:00
Bruno Cauet
06f0e1dee1 Port beets.logging to python 2.6
Multiple hacks :-)
2015-01-05 09:21:11 +01:00
Bruno Cauet
52243269fc Make test/test_logging work on python 2.6 2015-01-04 17:14:34 +01:00
Bruno Cauet
408afa1b58 Add tests for beets.logging 2015-01-04 17:02:28 +01:00