Robert Brewer avatar Robert Brewer committed 807c434

Test fixes.

Comments (0)

Files changed (7)


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


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


             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.
         if hasattr(engine, "console_control_handler"):
-        #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:
+        for name, server in getattr(cherrypy, 'servers', {}).items():
+            server.unsubscribe()
+            del cherrypy.servers[name]
                          'environment': "test_suite",
         if supervisor.scheme == "https":
+            #baseconf['server.ssl_module'] = 'builtin'
             baseconf['server.ssl_certificate'] = serverpem
             baseconf['server.ssl_private_key'] = serverpem


             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()


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


 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() = True
         def sessions():


     import cStringIO as StringIO
 except ImportError:
     import StringIO
 _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",
-                    wfile = CP_fileobject(s, "wb", -1)
+                    wfile = CP_fileobject(s, "wb", DEFAULT_BUFFER_SIZE)
                     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
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.