summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/test_utils.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-06-13 10:05:15 (GMT)
committerGitHub <noreply@github.com>2018-06-13 10:05:15 (GMT)
commit142e3c08a40c75b5788474b0defe7d5c0671f675 (patch)
tree949c50cbff8fed695ef04e05d28485f133ca9580 /Lib/asyncio/test_utils.py
parent961332dfd3dbff4c63ed4d9f8b5de937aa63475b (diff)
downloadcpython-142e3c08a40c75b5788474b0defe7d5c0671f675.zip
cpython-142e3c08a40c75b5788474b0defe7d5c0671f675.tar.gz
cpython-142e3c08a40c75b5788474b0defe7d5c0671f675.tar.bz2
[3.6] bpo-32356: idempotent pause_/resume_reading (GH-4914) (GH-7629)
Backport note: don't add new is_reading() method from master to 3.6. (cherry picked from commit d757aaf9dd767d13205bf9917e520ebf43e7f6e5)
Diffstat (limited to 'Lib/asyncio/test_utils.py')
-rw-r--r--Lib/asyncio/test_utils.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/Lib/asyncio/test_utils.py b/Lib/asyncio/test_utils.py
index 8b8c22a..f417204 100644
--- a/Lib/asyncio/test_utils.py
+++ b/Lib/asyncio/test_utils.py
@@ -335,12 +335,19 @@ class TestLoop(base_events.BaseEventLoop):
return False
def assert_reader(self, fd, callback, *args):
- assert fd in self.readers, 'fd {} is not registered'.format(fd)
+ if fd not in self.readers:
+ raise AssertionError(f'fd {fd} is not registered')
handle = self.readers[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'unexpected callback: {handle._callback} != {callback}')
+ if handle._args != args:
+ raise AssertionError(
+ f'unexpected callback args: {handle._args} != {args}')
+
+ def assert_no_reader(self, fd):
+ if fd in self.readers:
+ raise AssertionError(f'fd {fd} is registered')
def _add_writer(self, fd, callback, *args):
self.writers[fd] = events.Handle(callback, args, self)