diff options
-rw-r--r-- | Lib/test/test_asyncio/test_events.py | 18 | ||||
-rw-r--r-- | Lib/test/test_asyncio/test_tasks.py | 2 | ||||
-rw-r--r-- | 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 index 7b9839c..2338546 100644 --- a/Lib/test/test_asyncio/test_events.py +++ b/Lib/test/test_asyncio/test_events.py @@ -472,8 +472,8 @@ class EventLoopTestsMixin: 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 @@ class EventLoopTestsMixin: 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 @@ class EventLoopTestsMixin: 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 @@ class EventLoopTestsMixin: 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 @@ class EventLoopTestsMixin: 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 index 57fb053..8f0d081 100644 --- a/Lib/test/test_asyncio/test_tasks.py +++ b/Lib/test/test_asyncio/test_tasks.py @@ -779,7 +779,7 @@ class TaskTests(unittest.TestCase): 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 index ea1c08c..af86be1 100644 --- a/Lib/test/test_asyncio/test_unix_events.py +++ b/Lib/test/test_asyncio/test_unix_events.py @@ -67,7 +67,7 @@ class SelectorEventLoopTests(unittest.TestCase): 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') |