mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-23819: Get rid of assert statements in test_asyncio (GH-30212)
To keep checks even if run tests with optimized Python. Either use special assertion methods like assertEqual() or raise an AssertionError explicitly.
This commit is contained in:
parent
7c5c3f7254
commit
6ca78affc8
10 changed files with 102 additions and 63 deletions
|
@ -409,12 +409,13 @@ class TestLoop(base_events.BaseEventLoop):
|
|||
return False
|
||||
|
||||
def assert_writer(self, fd, callback, *args):
|
||||
assert fd in self.writers, 'fd {} is not registered'.format(fd)
|
||||
if fd not in self.writers:
|
||||
raise AssertionError(f'fd {fd} is not registered')
|
||||
handle = self.writers[fd]
|
||||
assert handle._callback == callback, '{!r} != {!r}'.format(
|
||||
handle._callback, callback)
|
||||
assert handle._args == args, '{!r} != {!r}'.format(
|
||||
handle._args, args)
|
||||
if handle._callback != callback:
|
||||
raise AssertionError(f'{handle._callback!r} != {callback!r}')
|
||||
if handle._args != args:
|
||||
raise AssertionError(f'{handle._args!r} != {args!r}')
|
||||
|
||||
def _ensure_fd_no_transport(self, fd):
|
||||
if not isinstance(fd, int):
|
||||
|
@ -530,7 +531,8 @@ class TestCase(unittest.TestCase):
|
|||
thread.join()
|
||||
|
||||
def set_event_loop(self, loop, *, cleanup=True):
|
||||
assert loop is not None
|
||||
if loop is None:
|
||||
raise AssertionError('loop is None')
|
||||
# ensure that the event loop is passed explicitly in asyncio
|
||||
events.set_event_loop(None)
|
||||
if cleanup:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue