Ticket #6042: 6042_introom.patch

File 6042_introom.patch, 6.2 KB (added by eddie, 8 years ago)
  • twisted/protocols/test/test_basic.py

     
    264264        t = proto_helpers.StringIOWithoutClosing()
    265265        a.makeConnection(protocol.FileWrapper(t))
    266266        a.dataReceived(b'produce\nhello world\nunproduce\ngoodbye\n')
    267         self.assertEqual(a.received,
    268                           [b'produce', b'hello world', b'unproduce', b'goodbye'])
     267        self.assertEqual(
     268            a.received,[b'produce', b'hello world', b'unproduce', b'goodbye'])
    269269
    270270
    271271    def test_clearLineBuffer(self):
     
    688688        self.assertRaises(NotImplementedError, proto.stringReceived, 'foo')
    689689
    690690
    691     def test_deprecatedModuleAttributes(self):
    692         """
    693         Accessing one of the old module attributes used by the
    694         NetstringReceiver parser emits a deprecation warning.
    695         """
    696         basic.LENGTH, basic.DATA, basic.COMMA, basic.NUMBER
    697         warnings = self.flushWarnings(
    698             offendingFunctions=[self.test_deprecatedModuleAttributes])
    699691
    700         self.assertEqual(len(warnings), 4)
    701         for warning in warnings:
    702             self.assertEqual(warning['category'], DeprecationWarning)
    703         self.assertEqual(
    704             warnings[0]['message'],
    705             ("twisted.protocols.basic.LENGTH was deprecated in Twisted 10.2.0: "
    706              "NetstringReceiver parser state is private."))
    707         self.assertEqual(
    708             warnings[1]['message'],
    709             ("twisted.protocols.basic.DATA was deprecated in Twisted 10.2.0: "
    710              "NetstringReceiver parser state is private."))
    711         self.assertEqual(
    712             warnings[2]['message'],
    713             ("twisted.protocols.basic.COMMA was deprecated in Twisted 10.2.0: "
    714              "NetstringReceiver parser state is private."))
    715         self.assertEqual(
    716             warnings[3]['message'],
    717             ("twisted.protocols.basic.NUMBER was deprecated in Twisted 10.2.0: "
    718              "NetstringReceiver parser state is private."))
    719 
    720 
    721 
    722692class IntNTestCaseMixin(LPTestCaseMixin):
    723693    """
    724694    TestCase mixin for int-prefixed protocols.
     
    912882
    913883
    914884
    915 class Int32TestCase(unittest.SynchronousTestCase, IntNTestCaseMixin, RecvdAttributeMixin):
     885class Int32TestCase(unittest.SynchronousTestCase, IntNTestCaseMixin,
     886                    RecvdAttributeMixin):
    916887    """
    917888    Test case for int32-prefixed protocol
    918889    """
     
    942913
    943914
    944915
    945 class Int16TestCase(unittest.SynchronousTestCase, IntNTestCaseMixin, RecvdAttributeMixin):
     916class Int16TestCase(unittest.SynchronousTestCase, IntNTestCaseMixin,
     917                    RecvdAttributeMixin):
    946918    """
    947919    Test case for int16-prefixed protocol
    948920    """
     
    1000972
    1001973
    1002974
    1003 class Int8TestCase(unittest.SynchronousTestCase, IntNTestCaseMixin, RecvdAttributeMixin):
     975class Int8TestCase(unittest.SynchronousTestCase, IntNTestCaseMixin,
     976                   RecvdAttributeMixin):
    1004977    """
    1005978    Test case for int8-prefixed protocol
    1006979    """
     
    10321005
    10331006
    10341007class OnlyProducerTransport(object):
    1035     # Transport which isn't really a transport, just looks like one to
    1036     # 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    '''
    10371012
    10381013    paused = False
    10391014    disconnecting = False
     
    10561031
    10571032
    10581033class ConsumingProtocol(basic.LineReceiver):
    1059     # Protocol that really, really doesn't want any more bytes.
     1034    '''
     1035    Protocol that really, really doesn't want any more bytes.
     1036    '''
    10601037
    10611038    def lineReceived(self, line):
    10621039        self.transport.write(line)
     
    10651042
    10661043
    10671044class ProducerTestCase(unittest.SynchronousTestCase):
     1045    '''
     1046    Pause and resume a producer
     1047    '''
    10681048
    10691049    def testPauseResume(self):
     1050        '''
     1051        The producer should be paused when data is received and not paused when
     1052        resumed.
     1053        '''
    10701054        p = ConsumingProtocol()
    10711055        t = OnlyProducerTransport()
    10721056        p.makeConnection(t)
    10731057
    10741058        p.dataReceived(b'hello, ')
    1075         self.failIf(t.data)
    1076         self.failIf(t.paused)
    1077         self.failIf(p.paused)
     1059        self.assertEqual(t.data, [])
     1060        self.assertFalse(t.paused)
     1061        self.assertFalse(p.paused)
    10781062
    10791063        p.dataReceived(b'world\r\n')
    10801064
    10811065        self.assertEqual(t.data, [b'hello, world'])
    1082         self.failUnless(t.paused)
    1083         self.failUnless(p.paused)
     1066        self.assertTrue(t.paused)
     1067        self.assertTrue(p.paused)
    10841068
    10851069        p.resumeProducing()
    10861070
    1087         self.failIf(t.paused)
    1088         self.failIf(p.paused)
     1071        self.assertFalse(t.paused)
     1072        self.assertFalse(p.paused)
    10891073
    10901074        p.dataReceived(b'hello\r\nworld\r\n')
    10911075
    10921076        self.assertEqual(t.data, [b'hello, world', b'hello'])
    1093         self.failUnless(t.paused)
    1094         self.failUnless(p.paused)
     1077        self.assertTrue(t.paused)
     1078        self.assertTrue(p.paused)
    10951079
    10961080        p.resumeProducing()
    10971081        p.dataReceived(b'goodbye\r\n')
    10981082
    10991083        self.assertEqual(t.data, [b'hello, world', b'hello', b'world'])
    1100         self.failUnless(t.paused)
    1101         self.failUnless(p.paused)
     1084        self.assertTrue(t.paused)
     1085        self.assertTrue(p.paused)
    11021086
    11031087        p.resumeProducing()
    11041088
    1105         self.assertEqual(t.data, [b'hello, world', b'hello', b'world', b'goodbye'])
    1106         self.failUnless(t.paused)
    1107         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)
    11081093
    11091094        p.resumeProducing()
    11101095
    1111         self.assertEqual(t.data, [b'hello, world', b'hello', b'world', b'goodbye'])
    1112         self.failIf(t.paused)
    1113         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)
    11141100
    11151101
    11161102
  • twisted/protocols/topfiles/6042.removal

     
     1test_deprecatedModuleAttributes in twisted.protocols.test.test_basic has been removed.