Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 2002

Show
Ignore:
Timestamp:
06/29/08 23:40:27
Author:
fumanchu
Message:

WOOHOO. Fixed test_conn on nix.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/test/helper.py

    r2000 r2002  
    182182    if '--server' in sys.argv: 
    183183        # 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' 
    186186        setConfig(conf) 
    187187        cherrypy.engine.start() 
     
    201201        else: 
    202202            # 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' 
    205205            setConfig(conf) 
    206206            cherrypy.engine.start_with_callback(_test_main_thread) 
  • trunk/cherrypy/test/test_conn.py

    r2001 r2002  
    99import sys 
    1010import time 
    11 timeout = 0.
     11timeout =
    1212 
    1313 
     
    225225        self.assertEqual(response.status, 200) 
    226226        self.body = response.read() 
    227         self.assertBody("0.1"
     227        self.assertBody(str(timeout)
    228228         
    229229        # Make a second request on the same socket 
     
    238238         
    239239        # Wait for our socket timeout 
    240         time.sleep(timeout * 10
     240        time.sleep(timeout * 2
    241241         
    242242        # Make another request on the same socket, which should error 
     
    253253                          " as it should have: %s" % sys.exc_info()[1]) 
    254254        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()) 
    258259         
    259260        conn.close() 
     
    275276        conn.send('GET /hello HTTP/1.1') 
    276277        # Wait for our socket timeout 
    277         time.sleep(timeout * 10
     278        time.sleep(timeout * 2
    278279        response = conn.response_class(conn.sock, method="GET") 
    279280        response.begin() 
     
    586587        remote_data_conn = urllib.urlopen('%s://%s:%s/one_megabyte_of_a/' % 
    587588                                          (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) 
    595599        
    596         self.assertTrue(received_data) 
     600        self.assertEqual(len(buf), 1024 * 1024) 
     601        self.assertEqual(buf, "a" * 1024 * 1024) 
    597602        self.assertEqual(remaining, 0) 
    598603        remote_data_conn.close() 

Hosted by WebFaction

Log in as guest/cpguest to create tickets