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

Changeset 2462

Show
Ignore:
Timestamp:
06/24/09 00:16:43
Author:
fumanchu
Message:

Some cross ports from the python3 branch, including two test fixes.

Files:

Legend:

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

    r2460 r2462  
    118118                   307: "This resource has moved temporarily to <a href='%s'>%s</a>.", 
    119119                   }[status] 
    120             response.body = "<br />\n".join([msg % (u, u) for u in self.urls]) 
     120            msgs = [msg % (u, u) for u in self.urls] 
     121            response.body = "<br />\n".join(msgs) 
    121122            # Previous code may have set C-L, so we have to reset it 
    122123            # (allow finalize to set it). 
  • trunk/cherrypy/_cplogging.py

    r2460 r2462  
    77logfmt = logging.Formatter("%(message)s") 
    88import os 
    9 import rfc822 
    109import sys 
    1110 
     
    112111        """Return now() in Apache Common Log Format (no timezone).""" 
    113112        now = datetime.datetime.now() 
    114         month = rfc822._monthnames[now.month - 1].capitalize() 
     113        monthnames = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 
     114                      'jul', 'aug', 'sep', 'oct', 'nov', 'dec'] 
     115        month = monthnames[now.month - 1].capitalize() 
    115116        return ('[%02d/%s/%04d:%02d:%02d:%02d]' % 
    116117                (now.day, month, now.year, now.hour, now.minute, now.second)) 
  • trunk/cherrypy/lib/caching.py

    r2460 r2462  
    138138        while time: 
    139139            now = time.time() 
     140            # Must make a copy of expirations so it doesn't change size 
     141            # during iteration 
    140142            for expiration_time, objects in self.expirations.items(): 
    141143                if expiration_time <= now: 
  • trunk/cherrypy/test/benchmark.py

    r2437 r2462  
    218218            self.output = _cpmodpy.read_process(AB_PATH or "ab", self.args()) 
    219219        except: 
    220             print(_cperror.format_exc()
     220            print _cperror.format_exc(
    221221            raise 
    222222         
     
    247247        row = [c] 
    248248        for attr in attrs: 
    249             val = getattr(sess, attr
     249            val = float(getattr(sess, attr)
    250250            avg[attr] += float(val) 
    251251            row.append(val) 
     
    378378                print("\nUsing null Request object") 
    379379            try: 
    380                 run_standard_benchmarks() 
     380                try: 
     381                    run_standard_benchmarks() 
     382                except: 
     383                    print _cperror.format_exc() 
     384                    raise 
    381385            finally: 
    382386                cherrypy.engine.exit() 
  • trunk/cherrypy/test/test_bus.py

    r2407 r2462  
    7171         
    7272        for channel in channels: 
    73             self.assertRaises(TypeError, b.publish, channel, 123) 
     73            self.assertRaises(wspbus.ChannelFailures, b.publish, channel, 123) 
    7474            expected.append(msg % (1, channel, 123)) 
    7575         
  • trunk/cherrypy/test/test_static.py

    r2437 r2462  
    22test.prefer_parent_path() 
    33 
     4from httplib import HTTPConnection, HTTPSConnection 
    45try: 
    56    import cStringIO as StringIO 
     
    3334         
    3435        def tell(self): 
    35             return repr(self.f.input.tell()) 
     36            if self.f.input.closed: 
     37                return '' 
     38            return repr(self.f.input.tell()).rstrip('L') 
    3639        tell.exposed = True 
    3740         
     
    230233        body = '' 
    231234        remaining = BIGFILE_SIZE 
    232         # By this point, the webserver has already written one chunk to 
    233         # the socket and queued another. So we start with i=1. 
    234         i = 1 
    235235        while remaining > 0: 
    236             i += 1 
    237             s, h, b = helper.webtest.openURL( 
    238                 "/tell", headers=[], host=self.HOST, port=self.PORT) 
    239             if remaining != 65536: 
    240                 self.assertEqual(long(b), 65536 * i) 
    241236            data = response.fp.read(65536) 
    242237            if not data: 
     
    244239            body += data 
    245240            remaining -= len(data) 
     241             
     242            if self.scheme == "https": 
     243                newconn = HTTPSConnection 
     244            else: 
     245                newconn = HTTPConnection 
     246            s, h, b = helper.webtest.openURL( 
     247                "/tell", headers=[], host=self.HOST, port=self.PORT, 
     248                http_conn=newconn) 
     249            if not b: 
     250                # The file was closed on the server. 
     251                tell_position = BIGFILE_SIZE 
     252            else: 
     253                tell_position = int(b) 
     254             
     255            expected = len(body) 
     256            if tell_position >= BIGFILE_SIZE: 
     257                # We can't exactly control how much content the server asks for. 
     258                # Fudge it by only checking the first half of the reads. 
     259                if expected < (BIGFILE_SIZE / 2): 
     260                    self.fail( 
     261                        "The file should have advanced to position %r, but has " 
     262                        "already advanced to the end of the file. It may not be " 
     263                        "streamed as intended, or at the wrong chunk size (64k)" % 
     264                        expected) 
     265            elif tell_position < expected: 
     266                self.fail( 
     267                    "The file should have advanced to position %r, but has " 
     268                    "only advanced to position %r. It may not be streamed " 
     269                    "as intended, or at the wrong chunk size (65536)" % 
     270                    (expected, tell_position)) 
    246271         
    247272        if body != "x" * BIGFILE_SIZE: 

Hosted by WebFaction

Log in as guest/cpguest to create tickets