~ubuntu-branches/ubuntu/lucid/python2.6/lucid

« back to all changes in this revision

Viewing changes to Lib/test/test_timeout.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-03-11 13:30:19 UTC
  • mto: (10.1.13 sid)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: james.westby@ubuntu.com-20100311133019-sblbooa3uqrkoe70
Tags: upstream-2.6.5~rc2
ImportĀ upstreamĀ versionĀ 2.6.5~rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
101
101
    def setUp(self):
102
102
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
103
103
        self.addr_remote = ('www.python.org.', 80)
104
 
        self.addr_local  = ('127.0.0.1', 25339)
 
104
        self.localhost = '127.0.0.1'
105
105
 
106
106
    def tearDown(self):
107
107
        self.sock.close()
146
146
        # Test accept() timeout
147
147
        _timeout = 2
148
148
        self.sock.settimeout(_timeout)
149
 
        self.sock.bind(self.addr_local)
 
149
        # Prevent "Address already in use" socket exceptions
 
150
        test_support.bind_port(self.sock, self.localhost)
150
151
        self.sock.listen(5)
151
152
 
152
153
        _t1 = time.time()
163
164
        _timeout = 2
164
165
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
165
166
        self.sock.settimeout(_timeout)
166
 
        self.sock.bind(self.addr_local)
 
167
        # Prevent "Address already in use" socket exceptions
 
168
        test_support.bind_port(self.sock, self.localhost)
167
169
 
168
170
        _t1 = time.time()
169
171
        self.failUnlessRaises(socket.error, self.sock.recvfrom, 8192)