beets/test
ThinkChaos b0caac871a fix: enable tracebacks for "user"/custom sqlite functions
A bit niche but I tried setting my bareasc prefix to an empty string,
and was getting an obtuse error. This should help make clearer what is
happening when queries fail.

The exception is not properly raised up the stack in the first place
because it happens across 2 FFI boundaries: the DB query
(Python -> SQLite), and the custom DB function (SQLite -> Python).
Thus Python cannot forwarded it back to itself through SQLite, and it's
treated as an "unraisable" exception.

We could override `sys.unraisablehook` to not print anything for the
original exception, and store it in a global for the outer Python
interpreter to fetch and raise properly, but that's pretty hacky,
limited to a single DB instance and query at once, and risks swallowing
other "unraisable" exceptions.
Instead we just tell the user to look above for what Python prints.

Sample output:
```
Exception ignored in: <function unidecode_expect_ascii at
0x7f7fa20bb060>
Traceback (most recent call last):
  File "site-packages/unidecode/__init__.py", line 60, in
unidecode_expect_ascii
    bytestring = string.encode('ASCII')
                 ^^^^^^^^^^^^^
AttributeError: 'bytes' object has no attribute 'encode'
Traceback (most recent call last):
  File "site-packages/beets/dbcore/db.py", line 988, in query
    cursor = self.db._connection().execute(statement, subvals)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sqlite3.OperationalError: user-defined function raised exception

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "site-packages/beets/__main__.py", line 9, in <module>
    sys.exit(main())
             ^^^^^^
  File "site-packages/beets/ui/__init__.py", line 1865, in main
    _raw_main(args)
  File "site-packages/beets/ui/__init__.py", line 1852, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "site-packages/beets/ui/commands.py", line 1599, in list_func
    list_items(lib, decargs(args), opts.album)
  File "site-packages/beets/ui/commands.py", line 1594, in list_items
    for item in lib.items(query):
                ^^^^^^^^^^^^^^^^
  File "site-packages/beets/library.py", line 1695, in items
    return self._fetch(Item, query, sort or
self.get_default_item_sort())

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/beets/library.py", line 1673, in _fetch
    return super()._fetch(model_cls, query, sort)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/beets/dbcore/db.py", line 1301, in _fetch
    rows = tx.query(sql, subvals)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/beets/dbcore/db.py", line 991, in query
    raise DBCustomFunctionError()
beets.dbcore.db.DBCustomFunctionError: beets defined SQLite function
failed; see the other errors above for details
```
2025-09-19 21:11:51 +01:00
..
autotag Rewrite distance tests 2025-05-31 19:17:43 +01:00
plugins lyrics: xfail sweetslyrics end-to-end test 2025-08-30 23:10:22 +01:00
rsrc Replace flowery language (#6002) 2025-09-15 09:02:22 +00:00
util Move human formatting functions under beets.util.units 2025-07-06 16:09:50 +01:00
__init__.py Remove unused imports 2021-08-26 20:59:48 +10:00
conftest.py Refactor test_query 2025-07-06 16:15:30 +01:00
test_art_resize.py Replace string concatenation (' + ') 2025-08-30 23:10:15 +01:00
test_autotag.py Move distance to a separate module 2025-05-31 19:17:43 +01:00
test_config_command.py Update CI config, minimum ruff version, docs and add changelog note 2024-12-10 06:10:03 +00:00
test_datequery.py Replace string concatenation (' + ') 2025-08-30 23:10:15 +01:00
test_dbcore.py fix: enable tracebacks for "user"/custom sqlite functions 2025-09-19 21:11:51 +01:00
test_files.py Replace assertIsDir 2025-07-09 09:21:50 +01:00
test_hidden.py Fix duplicate database change event send on Library.add (#5561) 2025-05-30 13:41:29 +00:00
test_importer.py importer: provides search_ids into lookup_candidates explicitly 2025-07-16 14:06:33 +01:00
test_library.py Replace percent formatting 2025-08-30 22:35:00 +01:00
test_logging.py Replace logging f-strings with arguments 2025-08-30 23:10:21 +01:00
test_m3ufile.py Reformat the codebase 2024-09-21 11:57:48 +01:00
test_metasync.py Reformat the codebase 2024-09-21 11:57:48 +01:00
test_pipeline.py pipeline: remove old tests, integrate with out test suite 2025-05-06 14:51:20 +02:00
test_plugins.py Merge branch 'master' into multivalued-flexible-fields 2025-08-19 13:39:34 +01:00
test_query.py Refactor test_query 2025-07-06 16:15:30 +01:00
test_release.py Update release conversion logic accordingly 2025-08-10 16:25:05 +01:00
test_sort.py Use unittest.TestCase for tests that don't require the dir setup 2025-05-26 12:40:38 +01:00
test_template.py Fix formatting 2025-05-07 10:41:01 +01:00
test_types.py Add NullPathType and types to PathType 2025-07-06 16:09:49 +01:00
test_ui.py Replace string concatenation (' + ') 2025-08-30 23:10:15 +01:00
test_ui_commands.py Rip away io stuff from TestHelper to IOMixin 2025-07-09 09:17:13 +01:00
test_ui_importer.py Fix lint issues 2024-09-21 11:59:18 +01:00
test_ui_init.py Speed up tests that only need IOMixin 2025-07-09 09:17:13 +01:00
test_util.py Simplify and speed up plurality/album tags retrieval tests 2025-05-31 19:17:42 +01:00
test_vfs.py Reformat the codebase 2024-09-21 11:57:48 +01:00
testall.py Remove def suite TestLoader definitions 2024-07-28 18:58:51 +01:00