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

Side by Side Diff: third_party/twisted_8_1/twisted/test/test_tpfile.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1
2 # Copyright (c) 2001-2004 Twisted Matrix Laboratories.
3 # See LICENSE for details.
4
5
6 from twisted.trial import unittest
7 from twisted.protocols import loopback
8 from twisted.protocols import basic
9 from twisted.internet import protocol, abstract
10
11 import StringIO
12
13 class BufferingServer(protocol.Protocol):
14 buffer = ''
15 def dataReceived(self, data):
16 self.buffer += data
17
18 class FileSendingClient(protocol.Protocol):
19 def __init__(self, f):
20 self.f = f
21
22 def connectionMade(self):
23 s = basic.FileSender()
24 d = s.beginFileTransfer(self.f, self.transport, lambda x: x)
25 d.addCallback(lambda r: self.transport.loseConnection())
26
27 class FileSenderTestCase(unittest.TestCase):
28 def testSendingFile(self):
29 testStr = 'xyz' * 100 + 'abc' * 100 + '123' * 100
30 s = BufferingServer()
31 c = FileSendingClient(StringIO.StringIO(testStr))
32
33 d = loopback.loopbackTCP(s, c)
34 d.addCallback(lambda x : self.assertEquals(s.buffer, testStr))
35 return d
36
37 def testSendingEmptyFile(self):
38 fileSender = basic.FileSender()
39 consumer = abstract.FileDescriptor()
40 consumer.connected = 1
41 emptyFile = StringIO.StringIO('')
42
43 d = fileSender.beginFileTransfer(emptyFile, consumer, lambda x: x)
44
45 # The producer will be immediately exhausted, and so immediately
46 # unregistered
47 self.assertEqual(consumer.producer, None)
48
49 # Which means the Deferred from FileSender should have been called
50 self.failUnless(d.called,
51 'producer unregistered with deferred being called')
52
OLDNEW
« no previous file with comments | « third_party/twisted_8_1/twisted/test/test_timeoutqueue.py ('k') | third_party/twisted_8_1/twisted/test/test_twistd.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698