py::test_get_all_happy_path failed with error: Test failed with exception
deletion_triggers = <class 'database.model.concept.concept.AIoDConcept'>
@pytest.fixture(scope="session")
def engine(deletion_triggers) -> Iterator[Engine]:
"""
Create a SqlAlchemy engine for tests, backed by a temporary sqlite file.
"""
temporary_file = tempfile.NamedTemporaryFile()
engine = create_engine(f"sqlite:///{temporary_file.name}?check_same_thread=False")
AIoDConcept.metadata.create_all(engine)
> EngineSingleton().patch(engine)
src/tests/testutils/default_sqlalchemy.py:38:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/database/session.py:21: in __init__
self.engine = create_engine(db_url(), echo=False, pool_recycle=3600)
venv/lib/python3.11/site-packages/sqlalchemy/util/deprecations.py:281: in warned
return fn(*args, **kwargs) # type: ignore[no-any-return]
venv/lib/python3.11/site-packages/sqlalchemy/engine/create.py:599: in create_engine
dbapi = dbapi_meth(**dbapi_args)
venv/lib/python3.11/site-packages/sqlalchemy/dialects/mysql/mysqldb.py:147: in import_dbapi
return __import__("MySQLdb")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
"""
MySQLdb - A DB API v2.0 compatible interface to MySQL.
This package is a wrapper around _mysql, which mostly implements the
MySQL C API.
connect() -- connects to server
See the C API specification and the MySQL documentation for more info
on other items.
For information on how MySQLdb handles type conversion, see the
MySQLdb.converters module.
"""
from .release import version_info
> from . import _mysql
E ImportError: dlopen(/Users/jmatias/Documents/develop/AIOD-rest-api/venv/lib/python3.11/site-packages/MySQLdb/_mysql.cpython-311-darwin.so, 0x0002): Library not loaded: /opt/homebrew/opt/mysql/lib/libmysqlclient.22.dylib
E Referenced from: <094163CF-9660-37E3-978E-50FE60955C55> /Users/jmatias/Documents/develop/AIOD-rest-api/venv/lib/python3.11/site-packages/MySQLdb/_mysql.cpython-311-darwin.so
E Reason: tried: '/opt/homebrew/opt/mysql/lib/libmysqlclient.22.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/mysql/lib/libmysqlclient.22.dylib' (no such file), '/opt/homebrew/opt/mysql/lib/libmysqlclient.22.dylib' (no such file), '/opt/homebrew/Cellar/mysql/8.3.0_1/lib/libmysqlclient.22.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/mysql/8.3.0_1/lib/libmysqlclient.22.dylib' (no such file), '/opt/homebrew/Cellar/mysql/8.3.0_1/lib/libmysqlclient.22.dylib' (no such file)
venv/lib/python3.11/site-packages/MySQLdb/__init__.py:17: ImportError
Solution:
Updating it to the most recent version (mysqlclient==v2.2.4) solves the issue for this platform.
All the unit tests started failing on the following system due to current
mysqlclient v.2.2.1
:Full error:
Solution: Updating it to the most recent version (
mysqlclient==v2.2.4
) solves the issue for this platform.