Changeset 1019
- Timestamp:
- 03/28/06 12:20:46
- Files:
-
- trunk/cherrypy/test/test_http.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/test/test_http.py
r1017 r1019 18 18 data = object() 19 19 20 def get_instances(cls): 21 return [x for x in gc.get_objects() if isinstance(x, cls)] 22 20 23 def setup_server(): 24 21 25 class Root: 22 26 def index(self, *args, **kwargs): … … 24 28 return "Hello world!" 25 29 index.exposed = True 30 31 def gc_stats(self): 32 return "%s %s %s %s" % (gc.collect(), 33 len(get_instances(_cphttptools.Request)), 34 len(get_instances(_cphttptools.Response)), 35 len(gc.get_referrers(data))) 36 gc_stats.exposed = True 26 37 cherrypy.tree.mount(Root()) 27 38 28 39 cherrypy.config.update({ 29 40 'global': {'server.log_to_screen': False, … … 39 50 40 51 def test_sockets(self): 41 if cherrypy.server.httpserver: 42 # By not including a Content-Length header, cgi.FieldStorage 43 # will hang. Verify that CP times out the socket and responds 44 # with 411 Length Required. 45 c = httplib.HTTPConnection("localhost:%s" % self.PORT) 46 c.request("POST", "/") 47 self.assertEqual(c.getresponse().status, 411) 48 49 50 def get_instances(cls): 51 return [x for x in gc.get_objects() if isinstance(x, cls)] 52 # By not including a Content-Length header, cgi.FieldStorage 53 # will hang. Verify that CP times out the socket and responds 54 # with 411 Length Required. 55 c = httplib.HTTPConnection("localhost:%s" % self.PORT) 56 c.request("POST", "/") 57 self.assertEqual(c.getresponse().status, 411) 52 58 53 59 … … 60 66 61 67 ts = [] 62 for _ in range( 100):68 for _ in range(25): 63 69 t = threading.Thread(target=getpage) 64 70 ts.append(t) … … 68 74 t.join() 69 75 70 self.assertEqual(gc.collect(), 0) 71 self.assertEqual(len(get_instances(_cphttptools.Request)), 0) 72 self.assertEqual(len(get_instances(_cphttptools.Response)), 0) 73 self.assertEqual(len(gc.get_referrers(data)), 1) 76 self.getPage("/gc_stats") 77 self.assertBody("0 1 1 1") 74 78 75 79

