~landscape/zope3/newer-from-ztk

« back to all changes in this revision

Viewing changes to src/twisted/test/stdio_test_hostpeer.py

  • Committer: Thomas Hervé
  • Date: 2009-07-08 13:52:04 UTC
  • Revision ID: thomas@canonical.com-20090708135204-df5eesrthifpylf8
Remove twisted copy

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- test-case-name: twisted.test.test_stdio.StandardInputOutputTestCase.testHostAndPeer -*-
2
 
# Copyright (c) 2006 Twisted Matrix Laboratories.
3
 
# See LICENSE for details.
4
 
 
5
 
"""
6
 
Main program for the child process run by
7
 
L{twisted.test.test_stdio.StandardInputOutputTestCase.testHostAndPeer} to test
8
 
that ITransport.getHost() and ITransport.getPeer() work for process transports.
9
 
"""
10
 
 
11
 
import sys
12
 
 
13
 
from twisted.internet import stdio, protocol
14
 
from twisted.python import reflect
15
 
 
16
 
class HostPeerChild(protocol.Protocol):
17
 
    def connectionMade(self):
18
 
        self.transport.write('\n'.join([
19
 
            str(self.transport.getHost()),
20
 
            str(self.transport.getPeer())]))
21
 
        self.transport.loseConnection()
22
 
 
23
 
 
24
 
    def connectionLost(self, reason):
25
 
        reactor.stop()
26
 
 
27
 
 
28
 
if __name__ == '__main__':
29
 
    reflect.namedAny(sys.argv[1]).install()
30
 
    from twisted.internet import reactor
31
 
    stdio.StandardIO(HostPeerChild())
32
 
    reactor.run()