You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running tests with Tortoise ORM in a Python 3.12 environment, a DeprecationWarning is raised due to the usage of asyncio.get_event_loop(). This function's behavior has changed in Python 3.10+, and as of Python 3.12, it raises a DeprecationWarning instead of returning a default loop when there is no current event loop.
Steps to Reproduce
Use Python 3.12.1 or newer.
Install Tortoise ORM version 0.23.0.
Run tests with pytest or similar tools that leverage tortoise.contrib.test.
Expected Behavior
The library should use asyncio.new_event_loop() or a similar approach to avoid the deprecation warning and ensure compatibility with Python 3.12+.
Actual Behavior
The following warning appears in the test output:
DeprecationWarning: There is no current event loop
loop = loop or asyncio.get_event_loop()
Environment
Python version: 3.12.1
Tortoise ORM version: 0.23.0
Operating System: macOS
Suggested Fix
Replace the usage of asyncio.get_event_loop() with asyncio.new_event_loop() in tortoise.contrib.test.__init__.py.
For example:
loop = loop or asyncio.new_event_loop()
Alternatively, ensure that a default event loop is created and set explicitly during the testing phase.
The text was updated successfully, but these errors were encountered:
Description
When running tests with
Tortoise ORM
in a Python 3.12 environment, aDeprecationWarning
is raised due to the usage ofasyncio.get_event_loop()
. This function's behavior has changed in Python 3.10+, and as of Python 3.12, it raises aDeprecationWarning
instead of returning a default loop when there is no current event loop.Steps to Reproduce
Use Python 3.12.1 or newer.
Install
Tortoise ORM
version 0.23.0.Run tests with
pytest
or similar tools that leveragetortoise.contrib.test
.Expected Behavior
The library should use
asyncio.new_event_loop()
or a similar approach to avoid the deprecation warning and ensure compatibility with Python 3.12+.Actual Behavior
The following warning appears in the test output:
Environment
Suggested Fix
Replace the usage of
asyncio.get_event_loop()
withasyncio.new_event_loop()
intortoise.contrib.test.__init__.py
.For example:
Alternatively, ensure that a default event loop is created and set explicitly during the testing phase.
The text was updated successfully, but these errors were encountered: