Ticket #6042: 6042_introom_2.patch
File 6042_introom_2.patch, 5.4 KB (added by , 9 years ago) |
---|
-
twisted/protocols/test/test_basic.py
218 218 219 219 rawpauseOutput1 = [b'twiddle1', b'twiddle2', b'len 5', b'rawpause', b''] 220 220 rawpauseOutput2 = [b'twiddle1', b'twiddle2', b'len 5', b'rawpause', 221 221 b'12345', b'twiddle3'] 222 222 223 223 224 224 def test_rawPausing(self): … … 264 264 t = proto_helpers.StringIOWithoutClosing() 265 265 a.makeConnection(protocol.FileWrapper(t)) 266 266 a.dataReceived(b'produce\nhello world\nunproduce\ngoodbye\n') 267 self.assertEqual( a.received,268 267 self.assertEqual( 268 a.received, [b'produce', b'hello world', b'unproduce', b'goodbye']) 269 269 270 270 271 271 def test_clearLineBuffer(self): … … 630 630 """ 631 631 tooLong = self.netstringReceiver.MAX_LENGTH + 1 632 632 self.netstringReceiver.dataReceived(b"".join( 633 633 (bytes(tooLong), b":", b"a" * tooLong))) 634 634 self.assertTrue(self.transport.disconnecting) 635 635 636 636 … … 728 728 r = self.getProtocol() 729 729 r.sendString(b"b" * 16) 730 730 self.assertEqual(r.transport.value(), 731 struct.pack(r.structFormat, 16) + b"b" * 16)731 struct.pack(r.structFormat, 16) + b"b" * 16) 732 732 733 733 734 734 def test_lengthLimitExceeded(self): … … 882 882 883 883 884 884 885 class Int32TestCase(unittest.SynchronousTestCase, IntNTestCaseMixin, RecvdAttributeMixin): 885 class Int32TestCase(unittest.SynchronousTestCase, IntNTestCaseMixin, 886 RecvdAttributeMixin): 886 887 """ 887 888 Test case for int32-prefixed protocol 888 889 """ … … 912 913 913 914 914 915 915 class Int16TestCase(unittest.SynchronousTestCase, IntNTestCaseMixin, RecvdAttributeMixin): 916 class Int16TestCase(unittest.SynchronousTestCase, IntNTestCaseMixin, 917 RecvdAttributeMixin): 916 918 """ 917 919 Test case for int16-prefixed protocol 918 920 """ … … 970 972 971 973 972 974 973 class Int8TestCase(unittest.SynchronousTestCase, IntNTestCaseMixin, RecvdAttributeMixin): 975 class Int8TestCase(unittest.SynchronousTestCase, IntNTestCaseMixin, 976 RecvdAttributeMixin): 974 977 """ 975 978 Test case for int8-prefixed protocol 976 979 """ … … 1002 1005 1003 1006 1004 1007 class OnlyProducerTransport(object): 1005 # Transport which isn't really a transport, just looks like one to 1006 # someone not looking very hard. 1008 """ 1009 Transport which isn't really a transport, just looks like one to 1010 someone not looking very hard. 1011 """ 1007 1012 1008 1013 paused = False 1009 1014 disconnecting = False … … 1026 1031 1027 1032 1028 1033 class ConsumingProtocol(basic.LineReceiver): 1029 # Protocol that really, really doesn't want any more bytes. 1034 """ 1035 Protocol that really, really doesn't want any more bytes. 1036 """ 1030 1037 1031 1038 def lineReceived(self, line): 1032 1039 self.transport.write(line) … … 1035 1042 1036 1043 1037 1044 class ProducerTestCase(unittest.SynchronousTestCase): 1045 """ 1046 Pause and resume a producer. 1047 """ 1038 1048 1039 1049 def testPauseResume(self): 1050 """ 1051 The producer should be paused when data is received and not paused when 1052 resumed. 1053 """ 1040 1054 p = ConsumingProtocol() 1041 1055 t = OnlyProducerTransport() 1042 1056 p.makeConnection(t) 1043 1057 1044 1058 p.dataReceived(b'hello, ') 1045 self. failIf(t.data)1046 self. failIf(t.paused)1047 self. failIf(p.paused)1059 self.assertEqual(t.data, []) 1060 self.assertFalse(t.paused) 1061 self.assertFalse(p.paused) 1048 1062 1049 1063 p.dataReceived(b'world\r\n') 1050 1064 1051 1065 self.assertEqual(t.data, [b'hello, world']) 1052 self. failUnless(t.paused)1053 self. failUnless(p.paused)1066 self.assertTrue(t.paused) 1067 self.assertTrue(p.paused) 1054 1068 1055 1069 p.resumeProducing() 1056 1070 1057 self. failIf(t.paused)1058 self. failIf(p.paused)1071 self.assertFalse(t.paused) 1072 self.assertFalse(p.paused) 1059 1073 1060 1074 p.dataReceived(b'hello\r\nworld\r\n') 1061 1075 1062 1076 self.assertEqual(t.data, [b'hello, world', b'hello']) 1063 self. failUnless(t.paused)1064 self. failUnless(p.paused)1077 self.assertTrue(t.paused) 1078 self.assertTrue(p.paused) 1065 1079 1066 1080 p.resumeProducing() 1067 1081 p.dataReceived(b'goodbye\r\n') 1068 1082 1069 1083 self.assertEqual(t.data, [b'hello, world', b'hello', b'world']) 1070 self. failUnless(t.paused)1071 self. failUnless(p.paused)1084 self.assertTrue(t.paused) 1085 self.assertTrue(p.paused) 1072 1086 1073 1087 p.resumeProducing() 1074 1088 1075 self.assertEqual(t.data, [b'hello, world', b'hello', b'world', b'goodbye']) 1076 self.failUnless(t.paused) 1077 self.failUnless(p.paused) 1089 self.assertEqual( 1090 t.data, [b'hello, world', b'hello', b'world', b'goodbye']) 1091 self.assertTrue(t.paused) 1092 self.assertTrue(p.paused) 1078 1093 1079 1094 p.resumeProducing() 1080 1095 1081 self.assertEqual(t.data, [b'hello, world', b'hello', b'world', b'goodbye']) 1082 self.failIf(t.paused) 1083 self.failIf(p.paused) 1096 self.assertEqual( 1097 t.data, [b'hello, world', b'hello', b'world', b'goodbye']) 1098 self.assertFalse(t.paused) 1099 self.assertFalse(p.paused) 1084 1100 1085 1101 1086 1102