Skip to content
Closed
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
Next Next commit
Updated test_futures, test_futures2, test_locks, test_proactor_events…
…, test_queues, test_runners
  • Loading branch information
terryluan12 committed Dec 29, 2025
commit bc8c54fc042565f93bebd4f33d984c3ba4e9de72
2 changes: 1 addition & 1 deletion Lib/test/test_asyncio/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from . import load_tests
from test.test_asyncio import load_tests
import unittest

unittest.main()
13 changes: 13 additions & 0 deletions Lib/test/test_asyncio/test_futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ def test_exception(self):
self.assertRaises(asyncio.InvalidStateError, f.set_exception, None)
self.assertFalse(f.cancel())

@unittest.skip('TODO: RUSTPYTHON')
# TypeError: StopIteration interacts badly with generators and cannot be raised into a Future'
def test_stop_iteration_exception(self, stop_iteration_class=StopIteration):
exc = stop_iteration_class()
f = self._new_future(loop=self.loop)
Expand Down Expand Up @@ -410,6 +412,10 @@ def func_repr(func):
self.assertEqual(repr(f_many_callbacks),
f'<{self.cls.__name__} cancelled>')

# TODO: RUSTPYTHON
# self.assertEqual(newf_tb.count('raise concurrent.futures.InvalidStateError'), 1)
# AssertionError: 0 != 1
@unittest.expectedFailure
def test_copy_state(self):
from asyncio.futures import _copy_future_state

Expand Down Expand Up @@ -654,6 +660,9 @@ def test_future_stop_iteration_args(self):
self.fail('StopIteration was expected')
self.assertEqual(result, (1, 2))

# TODO: RUSTPYTHON
# DeprecationWarning not triggered
@unittest.expectedFailure
def test_future_iter_throw(self):
fut = self._new_future(loop=self.loop)
fi = iter(fut)
Expand All @@ -678,6 +687,8 @@ def __del__(self):
fut = self._new_future(loop=self.loop)
fut.set_result(Evil())

@unittest.skip('TODO: RUSTPYTHON')
# NotImplementedError
def test_future_cancelled_result_refcycles(self):
f = self._new_future(loop=self.loop)
f.cancel()
Expand All @@ -689,6 +700,8 @@ def test_future_cancelled_result_refcycles(self):
self.assertIsNotNone(exc)
self.assertListEqual(gc.get_referrers(exc), [])

@unittest.skip('TODO: RUSTPYTHON')
# NotImplementedError
def test_future_cancelled_exception_refcycles(self):
f = self._new_future(loop=self.loop)
f.cancel()
Expand Down
13 changes: 9 additions & 4 deletions Lib/test/test_asyncio/test_futures2.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ def tearDownModule():

class FutureTests:

# TODO: RUSTPYTHON
# self.assertEqual(tb.count("await future"), 1)
# AssertionError: 0 != 1
@unittest.expectedFailure
async def test_future_traceback(self):

async def raise_exc():
Expand Down Expand Up @@ -68,10 +72,11 @@ def callback():
await asyncio.sleep(0)
self.assertTrue(exc_handler_called)

@unittest.skipUnless(hasattr(tasks, '_CTask'),
'requires the C _asyncio module')
class CFutureTests(FutureTests, unittest.IsolatedAsyncioTestCase):
cls = tasks._CTask
# TODO: RUSTPYTHON
# @unittest.skipUnless(hasattr(tasks, '_CTask'),
# 'requires the C _asyncio module')
# class CFutureTests(FutureTests, unittest.IsolatedAsyncioTestCase):
# cls = tasks._CTask

class PyFutureTests(FutureTests, unittest.IsolatedAsyncioTestCase):
cls = tasks._PyTask
Expand Down
13 changes: 13 additions & 0 deletions Lib/test/test_asyncio/test_locks.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,9 @@ async def func():
# originally raised.
self.assertIs(err.exception, raised)

# TODO: RUSTPYTHON
# AssertionError: Tuples differ: () != ('foo',)
@unittest.expectedFailure
async def test_cancelled_error_re_aquire(self):
# Test that a cancelled error, received when re-aquiring lock,
# will be re-raised un-modified.
Expand Down Expand Up @@ -816,6 +819,9 @@ async def func():
# originally raised.
self.assertIs(err.exception, raised)

# TODO: RUSTPYTHON
# AssertionError: 1 != 0
@unittest.expectedFailure
async def test_cancelled_wakeup(self):
# Test that a task cancelled at the "same" time as it is woken
# up as part of a Condition.notify() does not result in a lost wakeup.
Expand Down Expand Up @@ -860,6 +866,9 @@ async def consumer():
condition.notify_all()
await c[1]

# TODO: RUSTPYTHON
# AssertionError: 1 != 0
@unittest.expectedFailure
async def test_cancelled_wakeup_relock(self):
# Test that a task cancelled at the "same" time as it is woken
# up as part of a Condition.notify() does not result in a lost wakeup.
Expand Down Expand Up @@ -1193,6 +1202,10 @@ async def c3(result):
await asyncio.gather(*tasks, return_exceptions=True)
self.assertEqual([2, 3], result)


# TODO: RUSTPYTHON
@unittest.skip('TODO: RUSTPYTHON')
# TypeError: An asyncio.Future, a coroutine or an awaitable is required
async def test_acquire_fifo_order_4(self):
# Test that a successfule `acquire()` will wake up multiple Tasks
# that were waiting in the Semaphore queue due to FIFO rules.
Expand Down
6 changes: 6 additions & 0 deletions Lib/test/test_asyncio/test_proactor_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,9 @@ def test_sendto_memoryview(self):
self.proactor.sendto.assert_called_with(
self.sock, b'data', addr=('0.0.0.0', 1234))

# TODO: RUSTPYTHON
# AssertionError: False is not true
@unittest.expectedFailure
def test_sendto_no_data(self):
transport = self.datagram_transport()
transport.sendto(b'', ('0.0.0.0', 1234))
Expand Down Expand Up @@ -629,6 +632,9 @@ def test_sendto_buffer_memoryview(self):
list(transport._buffer))
self.assertIsInstance(transport._buffer[1][0], bytes)

# TODO: RUSTPYTHON
# AssertionError: Lists differ: [(b'data1', ('0.0.0.0', 12345)), (b'', ('0.0.0.0', 12345))] != [(b'data1', ('0.0.0.0', 12345))]
@unittest.expectedFailure
def test_sendto_buffer_nodata(self):
data2 = b''
transport = self.datagram_transport()
Expand Down
8 changes: 6 additions & 2 deletions Lib/test/test_asyncio/test_queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,19 +702,23 @@ async def test_shutdown_immediate_with_unfinished(self):
self.assertTrue(join_task.done())
await join_task


@unittest.skip('TODO: RUSTPYTHON')
# AttributeError: 'Queue' object has no attribute 'shutdown'
class QueueShutdownTests(
_QueueShutdownTestMixin, unittest.IsolatedAsyncioTestCase
):
q_class = asyncio.Queue


@unittest.skip('TODO: RUSTPYTHON')
# AttributeError: 'LifoQueue' object has no attribute 'shutdown'
class LifoQueueShutdownTests(
_QueueShutdownTestMixin, unittest.IsolatedAsyncioTestCase
):
q_class = asyncio.LifoQueue


@unittest.skip('TODO: RUSTPYTHON')
# AttributeError: 'PriorityQueue' object has no attribute 'shutdown'
class PriorityQueueShutdownTests(
_QueueShutdownTestMixin, unittest.IsolatedAsyncioTestCase
):
Expand Down
8 changes: 8 additions & 0 deletions Lib/test/test_asyncio/test_runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ async def main():
'exception': test_utils.MockInstanceOf(ZeroDivisionError)
})

# TODO: RUSTPYTHON
# AssertionError: <frame object at 0x557603317f10> is not None
@unittest.expectedFailure
def test_asyncio_run_closes_gens_after_hanging_tasks_errors(self):
spinner = None
lazyboy = None
Expand Down Expand Up @@ -273,6 +276,8 @@ async def main():
asyncio.run(main(), loop_factory=factory)
factory.assert_called_once_with()

@unittest.skip('TODO: RUSTPYTHON')
# module 'asyncio' has no attribute 'EventLoop'
def test_loop_factory_default_event_loop(self):
async def main():
if sys.platform == "win32":
Expand Down Expand Up @@ -393,6 +398,9 @@ async def get_context():

self.assertEqual(2, runner.run(get_context()).get(cvar))

# TODO: RUSTPYTHON
# AssertionError: RuntimeWarning not triggered
@unittest.expectedFailure
def test_recursive_run(self):
async def g():
pass
Expand Down