Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Unified Diff: third_party/twisted_8_1/twisted/test/test_stateful.py

Issue 12261012: Remove third_party/twisted_8_1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/twisted_8_1/twisted/test/test_stateful.py
diff --git a/third_party/twisted_8_1/twisted/test/test_stateful.py b/third_party/twisted_8_1/twisted/test/test_stateful.py
deleted file mode 100644
index 19b7ab00ecd1bdb50a1f903d1013149a9be1cd51..0000000000000000000000000000000000000000
--- a/third_party/twisted_8_1/twisted/test/test_stateful.py
+++ /dev/null
@@ -1,74 +0,0 @@
-# Copyright (c) 2001-2007 Twisted Matrix Laboratories.
-# See LICENSE for details.
-
-
-"""
-Test cases for twisted.protocols.stateful
-"""
-
-from twisted.test import test_protocols
-from twisted.protocols.stateful import StatefulProtocol
-
-from struct import pack, unpack, calcsize
-
-
-class MyInt32StringReceiver(StatefulProtocol):
- """
- A stateful Int32StringReceiver.
- """
- MAX_LENGTH = 99999
- structFormat = "!I"
- prefixLength = calcsize(structFormat)
-
- def getInitialState(self):
- return self._getHeader, 4
-
- def _getHeader(self, msg):
- length, = unpack("!i", msg)
- if length > self.MAX_LENGTH:
- self.transport.loseConnection()
- return
- return self._getString, length
-
- def _getString(self, msg):
- self.stringReceived(msg)
- return self._getHeader, 4
-
- def stringReceived(self, msg):
- """
- Override this.
- """
- raise NotImplementedError
-
- def sendString(self, data):
- """
- Send an int32-prefixed string to the other end of the connection.
- """
- self.transport.write(pack(self.structFormat, len(data)) + data)
-
-
-class TestInt32(MyInt32StringReceiver):
- def connectionMade(self):
- self.received = []
-
- def stringReceived(self, s):
- self.received.append(s)
-
- MAX_LENGTH = 50
- closed = 0
-
- def connectionLost(self, reason):
- self.closed = 1
-
-
-class Int32TestCase(test_protocols.Int32TestCase):
- protocol = TestInt32
-
- def test_bigReceive(self):
- r = self.getProtocol()
- big = ""
- for s in self.strings * 4:
- big += pack("!i", len(s)) + s
- r.dataReceived(big)
- self.assertEquals(r.received, self.strings * 4)
-
« no previous file with comments | « third_party/twisted_8_1/twisted/test/test_sslverify.py ('k') | third_party/twisted_8_1/twisted/test/test_stdio.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698