Changeset 2002
- Timestamp:
- 06/29/08 23:40:27
- Files:
-
- trunk/cherrypy/test/helper.py (modified) (2 diffs)
- trunk/cherrypy/test/test_conn.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/test/helper.py
r2000 r2002 182 182 if '--server' in sys.argv: 183 183 # Run the test module server-side only; wait for Ctrl-C to break. 184 if conf is None:185 conf = {'server.socket_host': '0.0.0.0'}184 conf = conf or {} 185 conf['server.socket_host'] = '0.0.0.0' 186 186 setConfig(conf) 187 187 cherrypy.engine.start() … … 201 201 else: 202 202 # Run normally (both server and client in same process). 203 if conf is None:204 conf = {'server.socket_host': '127.0.0.1'}203 conf = conf or {} 204 conf['server.socket_host'] = '127.0.0.1' 205 205 setConfig(conf) 206 206 cherrypy.engine.start_with_callback(_test_main_thread) trunk/cherrypy/test/test_conn.py
r2001 r2002 9 9 import sys 10 10 import time 11 timeout = 0.111 timeout = 1 12 12 13 13 … … 225 225 self.assertEqual(response.status, 200) 226 226 self.body = response.read() 227 self.assertBody( "0.1")227 self.assertBody(str(timeout)) 228 228 229 229 # Make a second request on the same socket … … 238 238 239 239 # Wait for our socket timeout 240 time.sleep(timeout * 10)240 time.sleep(timeout * 2) 241 241 242 242 # Make another request on the same socket, which should error … … 253 253 " as it should have: %s" % sys.exc_info()[1]) 254 254 else: 255 self.fail("Writing to timed out socket didn't fail" 256 " as it should have: %s" % 257 response.read()) 255 if response.status != 408: 256 self.fail("Writing to timed out socket didn't fail" 257 " as it should have: %s" % 258 response.read()) 258 259 259 260 conn.close() … … 275 276 conn.send('GET /hello HTTP/1.1') 276 277 # Wait for our socket timeout 277 time.sleep(timeout * 10)278 time.sleep(timeout * 2) 278 279 response = conn.response_class(conn.sock, method="GET") 279 280 response.begin() … … 586 587 remote_data_conn = urllib.urlopen('%s://%s:%s/one_megabyte_of_a/' % 587 588 (self.scheme, self.HOST, self.PORT,)) 588 received_data = remote_data_conn.read(512) 589 time.sleep(6.0) 590 remaining = 1024*1024 - 512 591 received_data = ' ' 592 while remaining and received_data: 593 received_data = remote_data_conn.read(remaining) 594 remaining -= len(received_data) 589 buf = remote_data_conn.read(512) 590 time.sleep(timeout * 0.6) 591 remaining = (1024 * 1024) - 512 592 while remaining: 593 data = remote_data_conn.read(remaining) 594 if not data: 595 break 596 else: 597 buf += data 598 remaining -= len(data) 595 599 596 self.assertTrue(received_data) 600 self.assertEqual(len(buf), 1024 * 1024) 601 self.assertEqual(buf, "a" * 1024 * 1024) 597 602 self.assertEqual(remaining, 0) 598 603 remote_data_conn.close()

