summaryrefslogtreecommitdiff
path: root/Lib/test/test_asyncio/utils.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-12-20 04:50:45 -0800
committerGitHub <noreply@github.com>2021-12-20 14:50:45 +0200
commit95948169d75bed3936284ea2225e83e07ec5fe20 (patch)
tree269af5d88a76c674e7768f29644b0f57ca9f46da /Lib/test/test_asyncio/utils.py
parent0c0bd78ccf8e1eb1d8ecfce423daf2a2f8ca6d3b (diff)
downloadcpython-git-95948169d75bed3936284ea2225e83e07ec5fe20.tar.gz
bpo-23819: Get rid of assert statements in test_asyncio (GH-30212) (GH-30213)
To keep checks even if run tests with optimized Python. Either use special assertion methods like assertEqual() or raise an AssertionError explicitly. (cherry picked from commit 6ca78affc8023bc5023189d64d8050857662042a) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Lib/test/test_asyncio/utils.py')
-rw-r--r--Lib/test/test_asyncio/utils.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/Lib/test/test_asyncio/utils.py b/Lib/test/test_asyncio/utils.py
index 3765194cd0..0b9cde6878 100644
--- a/Lib/test/test_asyncio/utils.py
+++ b/Lib/test/test_asyncio/utils.py
@@ -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: