Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Restore accidentally removed test content, change mentions of 3.11 to…
… 3.10
  • Loading branch information
ambv committed Dec 6, 2022
commit 9994a6e30b262321c1a08d490470ba6584f1f66d
2 changes: 1 addition & 1 deletion Doc/library/asyncio-eventloop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ an event loop:
In Python 3.12 it will be an error.

.. note::
In Python versions 3.10.0--3.10.8 and 3.11.0 this function
In Python versions 3.10.0--3.10.8 this function
(and other functions which used it implicitly) emitted a
:exc:`DeprecationWarning` if there was no running event loop, even if
the current loop was set.
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/asyncio-policy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ asyncio ships with the following built-in policies:

On Windows, :class:`ProactorEventLoop` is now used by default.

.. deprecated:: 3.11.1
.. deprecated:: 3.10.9
:meth:`get_event_loop` now emits a :exc:`DeprecationWarning` if there
is no current event loop set and a new event loop has been implicitly
created. In Python 3.12 it will be an error.
Expand Down
32 changes: 27 additions & 5 deletions Lib/test/test_asyncio/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ async def test():
self.assertTrue(t.done())
self.assertEqual(t.result(), 'ok')

# Deprecated in 3.10, undeprecated in 3.11.1
# Deprecated in 3.10.0, undeprecated in 3.10.9
asyncio.set_event_loop(self.loop)
self.addCleanup(asyncio.set_event_loop, None)
t = asyncio.ensure_future(notmuch())
Expand All @@ -241,6 +241,28 @@ def notmuch():
self.assertTrue(t.done())
self.assertEqual(t.result(), 'ok')

a = notmuch()
self.addCleanup(a.close)
with self.assertRaisesRegex(RuntimeError, 'There is no current event loop'):
asyncio.ensure_future(a)

async def test():
return asyncio.ensure_future(notmuch())
t = self.loop.run_until_complete(test())
self.assertIs(t._loop, self.loop)
self.loop.run_until_complete(t)
self.assertTrue(t.done())
self.assertEqual(t.result(), 'ok')

# Deprecated in 3.10.0, undeprecated in 3.10.9
asyncio.set_event_loop(self.loop)
self.addCleanup(asyncio.set_event_loop, None)
t = asyncio.ensure_future(notmuch())
self.assertIs(t._loop, self.loop)
self.loop.run_until_complete(t)
self.assertTrue(t.done())
self.assertEqual(t.result(), 'ok')

def test_ensure_future_future(self):
f_orig = self.new_future(self.loop)
f_orig.set_result('ko')
Expand Down Expand Up @@ -1475,7 +1497,7 @@ async def test():
loop.run_until_complete(test())

def test_as_completed_coroutine_use_global_loop(self):
# Deprecated in 3.10
# Deprecated in 3.10.0, undeprecated in 3.10.9
async def coro():
return 42

Expand Down Expand Up @@ -1967,7 +1989,7 @@ async def test():
self.assertEqual(res, 42)

def test_shield_coroutine_use_global_loop(self):
# Deprecated in 3.10, undeprecated in 3.11.1
# Deprecated in 3.10.0, undeprecated in 3.10.9
async def coro():
return 42

Expand Down Expand Up @@ -3089,7 +3111,7 @@ async def gather():
self.assertEqual(fut.result(), [])

def test_constructor_empty_sequence_use_global_loop(self):
# Deprecated in 3.10, undeprecated in 3.11.1
# Deprecated in 3.10.0, undeprecated in 3.10.9
asyncio.set_event_loop(self.one_loop)
self.addCleanup(asyncio.set_event_loop, None)
fut = asyncio.gather()
Expand Down Expand Up @@ -3195,7 +3217,7 @@ async def gather():
self.one_loop.run_until_complete(fut)

def test_constructor_use_global_loop(self):
# Deprecated in 3.10, undeprecated in 3.11.1
# Deprecated in 3.10.0, undeprecated in 3.10.9
async def coro():
return 'abc'
asyncio.set_event_loop(self.other_loop)
Expand Down