spl0k / supysonic

Supysonic is a Python implementation of the Subsonic server API.
https://supysonic.readthedocs.io
GNU Affero General Public License v3.0
259 stars 57 forks source link

tests/frontend/test_user.py tries to import escape from flask #260

Closed tijuca closed 6 months ago

tijuca commented 6 months ago

The test file tests/frontend/test_user.py is using ecape from the flask package

https://github.com/spl0k/supysonic/blob/master/tests/frontend/test_user.py#L11

This isn't usable in Flask >= 3.x and so this test is failing with a installed Flask >= 3.

246s test_issue (tests.issue221.Issue221TestCase.test_issue) ... ok
246s test_issue (tests.issue85.Issue85TestCase.test_issue) ... ok
246s 
246s ======================================================================
246s ERROR: tests.frontend.test_user (unittest.loader._FailedTest.tests.frontend.test_user)
246s ----------------------------------------------------------------------
246s ImportError: Failed to import test module: tests.frontend.test_user
246s Traceback (most recent call last):
246s   File "/usr/lib/python3.11/unittest/loader.py", line 419, in _find_test_path
246s     module = self._get_module_from_name(name)
246s              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
246s   File "/usr/lib/python3.11/unittest/loader.py", line 362, in _get_module_from_name
246s     __import__(name)
246s   File "/tmp/autopkgtest-lxc.ex82zoxd/downtmp/autopkgtest_tmp/build/tests/frontend/test_user.py", line 11, in <module>
246s     from flask import escape
246s ImportError: cannot import name 'escape' from 'flask' (/usr/lib/python3/dist-packages/flask/__init__.py)
246s 
246s 
246s ----------------------------------------------------------------------

The suggested replacement is to use escape from markupsafe, this is also usable within older environments there Flask 2.x is installed.

diff --git a/tests/frontend/test_user.py b/tests/frontend/test_user.py
index c1723cd..297eaaf 100644
--- a/tests/frontend/test_user.py
+++ b/tests/frontend/test_user.py
@@ -8,7 +8,7 @@
 import unittest
 import uuid

-from flask import escape
+from markupsafe import escape

 from supysonic.db import User, ClientPrefs