Robert Brewer avatar Robert Brewer committed 807c434

Test fixes.

Comments (0)

Files changed (7)

cherrypy/lib/caching.py

                 if expiration_time <= now:
                     for obj_size, uri, sel_header_values in objects:
                         try:
-                            del self.store[uri][sel_header_values]
+                            del self.store[uri][tuple(sel_header_values)]
                             self.tot_expires += 1
                             self.cursize -= obj_size
                         except KeyError:

cherrypy/process/wspbus.py

                 else:
                     d = t.isDaemon()
                 if not d:
+                    self.log("Waiting for thread %s." % t.getName())
                     t.join()
         
         if self.execv:

cherrypy/test/helper.py

             setattr(self, k, v)
 
 
+log_to_stderr = lambda msg, level: sys.stderr.write(msg + os.linesep)
+
 class LocalSupervisor(Supervisor):
     """Base class for modeling/controlling servers which run in the same process.
 
             engine.signal_handler.subscribe()
         if hasattr(engine, "console_control_handler"):
             engine.console_control_handler.subscribe()
-        #engine.subscribe('log', lambda msg, level: sys.stderr.write(msg + os.linesep))
+        #engine.subscribe('log', log_to_stderr)
 
     def start(self, modulename=None):
         """Load and start the HTTP server."""
         td = getattr(self, 'teardown', None)
         if td:
             td()
+        
+        for name, server in getattr(cherrypy, 'servers', {}).items():
+            server.unsubscribe()
+            del cherrypy.servers[name]
+        
         cherrypy.engine.exit()
 
 
                          'environment': "test_suite",
                          })
         if supervisor.scheme == "https":
+            #baseconf['server.ssl_module'] = 'builtin'
             baseconf['server.ssl_certificate'] = serverpem
             baseconf['server.ssl_private_key'] = serverpem
 

cherrypy/test/test_bus.py

         else:
             threads = [t for t in threading.enumerate() if not t.isDaemon()]
         self.assertEqual(len(threads), 1)
-        self.assertLog(['Bus STOPPING', 'Bus STOPPED',
-                        'Bus EXITING', 'Bus EXITED',
-                        'Waiting for child threads to terminate...'])
+        # The last message will mention an indeterminable thread name; ignore it
+        self.assertEqual(self._log_entries[:-1],
+                         ['Bus STOPPING', 'Bus STOPPED',
+                          'Bus EXITING', 'Bus EXITED',
+                          'Waiting for child threads to terminate...'])
 
     def test_start_with_callback(self):
         b = wspbus.Bus()

cherrypy/test/test_config_server.py

             # Also test default server.instance = builtin server
             'server.yetanother.socket_port': 9878,
             })
-
+    
     PORT = 9876
     
     def testBasicConfig(self):

cherrypy/test/test_tutorials.py

 
 
 class TutorialTest(helper.CPWebCase):
-    @staticmethod
-    def setup_server():
+    @classmethod
+    def setup_server(cls):
         
         conf = cherrypy.config.copy()
         
             app.root.sessions = sessions
             app.root.traceback_setting = traceback_setting
             
-            test.sync_apps()
+            cls.supervisor.sync_apps()
         load_tut_module.exposed = True
         
         def sessions():

cherrypy/wsgiserver/__init__.py

     import cStringIO as StringIO
 except ImportError:
     import StringIO
+DEFAULT_BUFFER_SIZE = -1
 
 _fileobject_uses_str_type = isinstance(socket._fileobject(None)._rbuf, basestring)
 
     remote_addr = None
     remote_port = None
     ssl_env = None
-    rbufsize = -1
+    rbufsize = DEFAULT_BUFFER_SIZE
+    wbufsize = DEFAULT_BUFFER_SIZE
     RequestHandlerClass = HTTPRequest
     
     def __init__(self, server, sock, makefile=CP_fileobject):
         self.server = server
         self.socket = sock
         self.rfile = makefile(sock, "rb", self.rbufsize)
-        self.wfile = makefile(sock, "wb", -1)
+        self.wfile = makefile(sock, "wb", self.wbufsize)
     
     def communicate(self):
         """Read each request and respond appropriately."""
         except NoSSLError:
             if req and not req.sent_headers:
                 # Unwrap our wfile
-                self.wfile = CP_fileobject(self.socket._sock, "wb", -1)
+                self.wfile = CP_fileobject(self.socket._sock, "wb", self.wbufsize)
                 req.simple_response("400 Bad Request",
                     "The client sent a plain HTTP request, but "
                     "this server only speaks HTTPS on this port.")
     Required methods:
     
         * ``wrap(sock) -> (wrapped socket, ssl environ dict)``
-        * ``makefile(sock, mode='r', bufsize=-1) -> socket file object``
+        * ``makefile(sock, mode='r', bufsize=DEFAULT_BUFFER_SIZE) -> socket file object``
     """
     
     def __init__(self, certificate, private_key, certificate_chain=None):
     def wrap(self, sock):
         raise NotImplemented
     
-    def makefile(self, sock, mode='r', bufsize=-1):
+    def makefile(self, sock, mode='r', bufsize=DEFAULT_BUFFER_SIZE):
         raise NotImplemented
 
 
                            "Content-Type: text/plain\r\n\r\n",
                            msg]
                     
-                    wfile = CP_fileobject(s, "wb", -1)
+                    wfile = CP_fileobject(s, "wb", DEFAULT_BUFFER_SIZE)
                     try:
                         wfile.sendall("".join(buf))
                     except socket.error, x:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.