[Python-checkins] cpython: Issue #19589: Use specific asserts in asyncio tests.
serhiy.storchaka
python-checkins at python.org
Thu Nov 14 22:11:35 CET 2013
http://hg.python.org/cpython/rev/7e00bdada290
changeset: 87100:7e00bdada290
user: Serhiy Storchaka <storchaka at gmail.com>
date: Thu Nov 14 23:10:51 2013 +0200
summary:
Issue #19589: Use specific asserts in asyncio tests.
files:
Lib/test/test_asyncio/test_events.py | 18 ++++++----
Lib/test/test_asyncio/test_tasks.py | 2 +-
Lib/test/test_asyncio/test_unix_events.py | 2 +-
3 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -472,8 +472,8 @@
f = self.loop.create_connection(
lambda: MyProto(loop=self.loop), *httpd.address)
tr, pr = self.loop.run_until_complete(f)
- self.assertTrue(isinstance(tr, transports.Transport))
- self.assertTrue(isinstance(pr, protocols.Protocol))
+ self.assertIsInstance(tr, transports.Transport)
+ self.assertIsInstance(pr, protocols.Protocol)
self.loop.run_until_complete(pr.done)
self.assertGreater(pr.nbytes, 0)
tr.close()
@@ -500,8 +500,8 @@
f = self.loop.create_connection(
lambda: MyProto(loop=self.loop), sock=sock)
tr, pr = self.loop.run_until_complete(f)
- self.assertTrue(isinstance(tr, transports.Transport))
- self.assertTrue(isinstance(pr, protocols.Protocol))
+ self.assertIsInstance(tr, transports.Transport)
+ self.assertIsInstance(pr, protocols.Protocol)
self.loop.run_until_complete(pr.done)
self.assertGreater(pr.nbytes, 0)
tr.close()
@@ -513,8 +513,8 @@
lambda: MyProto(loop=self.loop), *httpd.address,
ssl=test_utils.dummy_ssl_context())
tr, pr = self.loop.run_until_complete(f)
- self.assertTrue(isinstance(tr, transports.Transport))
- self.assertTrue(isinstance(pr, protocols.Protocol))
+ self.assertIsInstance(tr, transports.Transport)
+ self.assertIsInstance(pr, protocols.Protocol)
self.assertTrue('ssl' in tr.__class__.__name__.lower())
self.assertIsNotNone(tr.get_extra_info('sockname'))
self.loop.run_until_complete(pr.done)
@@ -926,7 +926,8 @@
r.setblocking(False)
f = self.loop.sock_recv(r, 1)
ov = getattr(f, 'ov', None)
- self.assertTrue(ov is None or ov.pending)
+ if ov is not None:
+ self.assertTrue(ov.pending)
@tasks.coroutine
def main():
@@ -949,7 +950,8 @@
self.assertLess(elapsed, 0.1)
self.assertEqual(t.result(), 'cancelled')
self.assertRaises(futures.CancelledError, f.result)
- self.assertTrue(ov is None or not ov.pending)
+ if ov is not None:
+ self.assertFalse(ov.pending)
self.loop._stop_serving(r)
r.close()
diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py
--- a/Lib/test/test_asyncio/test_tasks.py
+++ b/Lib/test/test_asyncio/test_tasks.py
@@ -779,7 +779,7 @@
self.assertEqual(len(res), 2, res)
self.assertEqual(res[0], (1, 'a'))
self.assertEqual(res[1][0], 2)
- self.assertTrue(isinstance(res[1][1], futures.TimeoutError))
+ self.assertIsInstance(res[1][1], futures.TimeoutError)
self.assertAlmostEqual(0.12, loop.time())
# move forward to close generator
diff --git a/Lib/test/test_asyncio/test_unix_events.py b/Lib/test/test_asyncio/test_unix_events.py
--- a/Lib/test/test_asyncio/test_unix_events.py
+++ b/Lib/test/test_asyncio/test_unix_events.py
@@ -67,7 +67,7 @@
cb = lambda: True
self.loop.add_signal_handler(signal.SIGHUP, cb)
h = self.loop._signal_handlers.get(signal.SIGHUP)
- self.assertTrue(isinstance(h, events.Handle))
+ self.assertIsInstance(h, events.Handle)
self.assertEqual(h._callback, cb)
@unittest.mock.patch('asyncio.unix_events.signal')
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list