All of the tests in tests/test_asgi.py are failing with Python 3.14.0rc2:
$ uv pip install -e . pytest asgiref
Resolved 7 packages in 2ms
Built prometheus-client @ file:///tmp/client_python
Prepared 1 package in 648ms
Installed 7 packages in 9ms
+ asgiref==3.9.1
+ iniconfig==2.1.0
+ packaging==25.0
+ pluggy==1.6.0
+ prometheus-client==0.23.0 (from file:///tmp/client_python)
+ pygments==2.19.2
+ pytest==8.4.2
$ .venv/bin/pytest tests/test_asgi.py -x
========================================================= test session starts =========================================================
platform linux -- Python 3.14.0rc2, pytest-8.4.2, pluggy-1.6.0
rootdir: /tmp/client_python
configfile: pyproject.toml
collected 9 items
tests/test_asgi.py FE
=============================================================== ERRORS ================================================================
_______________________________________________ ERROR at teardown of ASGITest.test_gzip _______________________________________________
self = <tests.test_asgi.ASGITest testMethod=test_gzip>
def tearDown(self):
if self.communicator:
> asyncio.get_event_loop().run_until_complete(
^^^^^^^^^^^^^^^^^^^^^^^^
self.communicator.wait()
)
tests/test_asgi.py:48:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <asyncio.unix_events._UnixDefaultEventLoopPolicy object at 0x7f893e9078c0>
def get_event_loop(self):
"""Get the event loop for the current context.
Returns an instance of EventLoop or raises an exception.
"""
if self._local._loop is None:
> raise RuntimeError('There is no current event loop in thread %r.'
% threading.current_thread().name)
E RuntimeError: There is no current event loop in thread 'MainThread'.
/usr/lib/python3.14/asyncio/events.py:715: RuntimeError
============================================================== FAILURES ===============================================================
_________________________________________________________ ASGITest.test_gzip __________________________________________________________
self = <tests.test_asgi.ASGITest testMethod=test_gzip>
def test_gzip(self):
# Increment a metric.
metric_name = "counter"
help_text = "A counter"
increments = 2
self.increment_metrics(metric_name, help_text, increments)
app = make_asgi_app(self.registry)
self.seed_app(app)
# Send input with gzip header.
self.scope["headers"] = [(b"accept-encoding", b"gzip")]
> self.send_input({"type": "http.request", "body": b""})
tests/test_asgi.py:163:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_asgi.py:56: in send_input
asyncio.get_event_loop().run_until_complete(
^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <asyncio.unix_events._UnixDefaultEventLoopPolicy object at 0x7f893e9078c0>
def get_event_loop(self):
"""Get the event loop for the current context.
Returns an instance of EventLoop or raises an exception.
"""
if self._local._loop is None:
> raise RuntimeError('There is no current event loop in thread %r.'
% threading.current_thread().name)
E RuntimeError: There is no current event loop in thread 'MainThread'.
/usr/lib/python3.14/asyncio/events.py:715: RuntimeError
======================================================= short test summary info =======================================================
FAILED tests/test_asgi.py::ASGITest::test_gzip - RuntimeError: There is no current event loop in thread 'MainThread'.
ERROR tests/test_asgi.py::ASGITest::test_gzip - RuntimeError: There is no current event loop in thread 'MainThread'.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 2 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
===================================================== 1 failed, 1 error in 0.15s ======================================================
Note that using asyncio.get_event_loop() to create a new event loop was deprecated, and in Python 3.14 it raises an exception instead. FWIU you need to create the event loop yourself (I gues in the setUp() method).
I can reproduce this with 0.23.0.
All of the tests in
tests/test_asgi.pyare failing with Python 3.14.0rc2:$ uv pip install -e . pytest asgiref Resolved 7 packages in 2ms Built prometheus-client @ file:///tmp/client_python Prepared 1 package in 648ms Installed 7 packages in 9ms + asgiref==3.9.1 + iniconfig==2.1.0 + packaging==25.0 + pluggy==1.6.0 + prometheus-client==0.23.0 (from file:///tmp/client_python) + pygments==2.19.2 + pytest==8.4.2 $ .venv/bin/pytest tests/test_asgi.py -x ========================================================= test session starts ========================================================= platform linux -- Python 3.14.0rc2, pytest-8.4.2, pluggy-1.6.0 rootdir: /tmp/client_python configfile: pyproject.toml collected 9 items tests/test_asgi.py FE =============================================================== ERRORS ================================================================ _______________________________________________ ERROR at teardown of ASGITest.test_gzip _______________________________________________ self = <tests.test_asgi.ASGITest testMethod=test_gzip> def tearDown(self): if self.communicator: > asyncio.get_event_loop().run_until_complete( ^^^^^^^^^^^^^^^^^^^^^^^^ self.communicator.wait() ) tests/test_asgi.py:48: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <asyncio.unix_events._UnixDefaultEventLoopPolicy object at 0x7f893e9078c0> def get_event_loop(self): """Get the event loop for the current context. Returns an instance of EventLoop or raises an exception. """ if self._local._loop is None: > raise RuntimeError('There is no current event loop in thread %r.' % threading.current_thread().name) E RuntimeError: There is no current event loop in thread 'MainThread'. /usr/lib/python3.14/asyncio/events.py:715: RuntimeError ============================================================== FAILURES =============================================================== _________________________________________________________ ASGITest.test_gzip __________________________________________________________ self = <tests.test_asgi.ASGITest testMethod=test_gzip> def test_gzip(self): # Increment a metric. metric_name = "counter" help_text = "A counter" increments = 2 self.increment_metrics(metric_name, help_text, increments) app = make_asgi_app(self.registry) self.seed_app(app) # Send input with gzip header. self.scope["headers"] = [(b"accept-encoding", b"gzip")] > self.send_input({"type": "http.request", "body": b""}) tests/test_asgi.py:163: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_asgi.py:56: in send_input asyncio.get_event_loop().run_until_complete( ^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <asyncio.unix_events._UnixDefaultEventLoopPolicy object at 0x7f893e9078c0> def get_event_loop(self): """Get the event loop for the current context. Returns an instance of EventLoop or raises an exception. """ if self._local._loop is None: > raise RuntimeError('There is no current event loop in thread %r.' % threading.current_thread().name) E RuntimeError: There is no current event loop in thread 'MainThread'. /usr/lib/python3.14/asyncio/events.py:715: RuntimeError ======================================================= short test summary info ======================================================= FAILED tests/test_asgi.py::ASGITest::test_gzip - RuntimeError: There is no current event loop in thread 'MainThread'. ERROR tests/test_asgi.py::ASGITest::test_gzip - RuntimeError: There is no current event loop in thread 'MainThread'. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 2 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ===================================================== 1 failed, 1 error in 0.15s ======================================================Note that using asyncio.get_event_loop() to create a new event loop was deprecated, and in Python 3.14 it raises an exception instead. FWIU you need to create the event loop yourself (I gues in the
setUp()method).I can reproduce this with 0.23.0.