diff options
author | Andrew Svetlov <andrew.svetlov@gmail.com> | 2018-12-11 17:07:05 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-11 17:07:05 (GMT) |
commit | 5344501ad166c1380be452644a863a4679c4291b (patch) | |
tree | 4a2d9f0b0a7225db78451d7720f4189694ea04a9 /Lib/test | |
parent | 7211d306d4c2f73732540759e20dd17bd18b3361 (diff) | |
download | cpython-5344501ad166c1380be452644a863a4679c4291b.zip cpython-5344501ad166c1380be452644a863a4679c4291b.tar.gz cpython-5344501ad166c1380be452644a863a4679c4291b.tar.bz2 |
bpo-35394: Add empty slots to abstract asyncio protocols (#10889)
* bpo-35394: Add empty slots to abstract asyncio protocols
* Add missing test file
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_asyncio/test_events.py | 24 | ||||
-rw-r--r-- | Lib/test/test_asyncio/test_protocols.py | 57 |
2 files changed, 57 insertions, 24 deletions
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py index b76cfb7..9311a20 100644 --- a/Lib/test/test_asyncio/test_events.py +++ b/Lib/test/test_asyncio/test_events.py @@ -2486,30 +2486,6 @@ class AbstractEventLoopTests(unittest.TestCase): loop.close() -class ProtocolsAbsTests(unittest.TestCase): - - def test_empty(self): - f = mock.Mock() - p = asyncio.Protocol() - self.assertIsNone(p.connection_made(f)) - self.assertIsNone(p.connection_lost(f)) - self.assertIsNone(p.data_received(f)) - self.assertIsNone(p.eof_received()) - - dp = asyncio.DatagramProtocol() - self.assertIsNone(dp.connection_made(f)) - self.assertIsNone(dp.connection_lost(f)) - self.assertIsNone(dp.error_received(f)) - self.assertIsNone(dp.datagram_received(f, f)) - - sp = asyncio.SubprocessProtocol() - self.assertIsNone(sp.connection_made(f)) - self.assertIsNone(sp.connection_lost(f)) - self.assertIsNone(sp.pipe_data_received(1, f)) - self.assertIsNone(sp.pipe_connection_lost(1, f)) - self.assertIsNone(sp.process_exited()) - - class PolicyTests(unittest.TestCase): def test_event_loop_policy(self): diff --git a/Lib/test/test_asyncio/test_protocols.py b/Lib/test/test_asyncio/test_protocols.py new file mode 100644 index 0000000..438111c --- /dev/null +++ b/Lib/test/test_asyncio/test_protocols.py @@ -0,0 +1,57 @@ +import unittest +from unittest import mock + +import asyncio + + +class ProtocolsAbsTests(unittest.TestCase): + + def test_base_protocol(self): + f = mock.Mock() + p = asyncio.BaseProtocol() + self.assertIsNone(p.connection_made(f)) + self.assertIsNone(p.connection_lost(f)) + self.assertIsNone(p.pause_writing()) + self.assertIsNone(p.resume_writing()) + self.assertFalse(hasattr(p, '__dict__')) + + def test_protocol(self): + f = mock.Mock() + p = asyncio.Protocol() + self.assertIsNone(p.connection_made(f)) + self.assertIsNone(p.connection_lost(f)) + self.assertIsNone(p.data_received(f)) + self.assertIsNone(p.eof_received()) + self.assertIsNone(p.pause_writing()) + self.assertIsNone(p.resume_writing()) + self.assertFalse(hasattr(p, '__dict__')) + + def test_buffered_protocol(self): + f = mock.Mock() + p = asyncio.BufferedProtocol() + self.assertIsNone(p.connection_made(f)) + self.assertIsNone(p.connection_lost(f)) + self.assertIsNone(p.get_buffer(100)) + self.assertIsNone(p.buffer_updated(150)) + self.assertIsNone(p.pause_writing()) + self.assertIsNone(p.resume_writing()) + self.assertFalse(hasattr(p, '__dict__')) + + def test_datagram_protocol(self): + f = mock.Mock() + dp = asyncio.DatagramProtocol() + self.assertIsNone(dp.connection_made(f)) + self.assertIsNone(dp.connection_lost(f)) + self.assertIsNone(dp.error_received(f)) + self.assertIsNone(dp.datagram_received(f, f)) + self.assertFalse(hasattr(dp, '__dict__')) + + def test_subprocess_protocol(self): + f = mock.Mock() + sp = asyncio.SubprocessProtocol() + self.assertIsNone(sp.connection_made(f)) + self.assertIsNone(sp.connection_lost(f)) + self.assertIsNone(sp.pipe_data_received(1, f)) + self.assertIsNone(sp.pipe_connection_lost(1, f)) + self.assertIsNone(sp.process_exited()) + self.assertFalse(hasattr(sp, '__dict__')) |