1import unittest 2from unittest import mock 3 4import asyncio 5 6 7class ProtocolsAbsTests(unittest.TestCase): 8 9 def test_base_protocol(self): 10 f = mock.Mock() 11 p = asyncio.BaseProtocol() 12 self.assertIsNone(p.connection_made(f)) 13 self.assertIsNone(p.connection_lost(f)) 14 self.assertIsNone(p.pause_writing()) 15 self.assertIsNone(p.resume_writing()) 16 self.assertFalse(hasattr(p, '__dict__')) 17 18 def test_protocol(self): 19 f = mock.Mock() 20 p = asyncio.Protocol() 21 self.assertIsNone(p.connection_made(f)) 22 self.assertIsNone(p.connection_lost(f)) 23 self.assertIsNone(p.data_received(f)) 24 self.assertIsNone(p.eof_received()) 25 self.assertIsNone(p.pause_writing()) 26 self.assertIsNone(p.resume_writing()) 27 self.assertFalse(hasattr(p, '__dict__')) 28 29 def test_buffered_protocol(self): 30 f = mock.Mock() 31 p = asyncio.BufferedProtocol() 32 self.assertIsNone(p.connection_made(f)) 33 self.assertIsNone(p.connection_lost(f)) 34 self.assertIsNone(p.get_buffer(100)) 35 self.assertIsNone(p.buffer_updated(150)) 36 self.assertIsNone(p.pause_writing()) 37 self.assertIsNone(p.resume_writing()) 38 self.assertFalse(hasattr(p, '__dict__')) 39 40 def test_datagram_protocol(self): 41 f = mock.Mock() 42 dp = asyncio.DatagramProtocol() 43 self.assertIsNone(dp.connection_made(f)) 44 self.assertIsNone(dp.connection_lost(f)) 45 self.assertIsNone(dp.error_received(f)) 46 self.assertIsNone(dp.datagram_received(f, f)) 47 self.assertFalse(hasattr(dp, '__dict__')) 48 49 def test_subprocess_protocol(self): 50 f = mock.Mock() 51 sp = asyncio.SubprocessProtocol() 52 self.assertIsNone(sp.connection_made(f)) 53 self.assertIsNone(sp.connection_lost(f)) 54 self.assertIsNone(sp.pipe_data_received(1, f)) 55 self.assertIsNone(sp.pipe_connection_lost(1, f)) 56 self.assertIsNone(sp.process_exited()) 57 self.assertFalse(hasattr(sp, '__dict__')) 58