Changeset 757
- Timestamp:
- 10/28/05 19:09:25
- Files:
-
- trunk/cherrypy/test/helper.py (modified) (2 diffs)
- trunk/cherrypy/test/test_core.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/test/helper.py
r699 r757 71 71 72 72 73 class VirtualRootFilter: 74 75 def __init__(self, prefix): 76 self.prefix = prefix 77 78 def onStartResource(self): 79 path = cherrypy.request.path 80 if path.startswith(self.prefix): 81 cherrypy.request.objectPath = path[len(self.prefix):] 82 vroot = "" 83 test_vrf = VirtualRootFilter(vroot) 84 85 73 86 class CPWebCase(webtest.WebCase): 74 87 … … 131 144 cherrypy.root._cpOnError = onerror 132 145 146 if vroot: 147 url = vroot + url 148 filters = getattr(cherrypy.root, "_cpFilterList", None) 149 if filters is None: 150 cherrypy.root._cpFilterList = filters = [] 151 if test_vrf not in filters: 152 filters.append(test_vrf) 153 133 154 if cherrypy.server.httpserver is None: 134 155 self._getRequest(url, headers, method, body) trunk/cherrypy/test/test_core.py
r755 r757 38 38 class Root: 39 39 40 _cpFilterList = []41 42 40 def index(self): 43 41 return "hello" 44 42 index.exposed = True 43 44 def andnow(self): 45 return "the larch" 46 andnow.exposed = True 45 47 46 48 def _global(self): … … 101 103 def bad(self): 102 104 cherrypy.response.status = "error" 103 return " hello"105 return "bad news" 104 106 105 107 … … 140 142 141 143 142 class Slash(Test):143 def index(self):144 return "slashed!"145 146 class VPrefix:147 def __init__(self, prefix):148 self.prefix = prefix149 def onStartResource(self):150 path = cherrypy.request.path151 if path.startswith(self.prefix):152 cherrypy.request.objectPath = path[len(self.prefix):]153 cherrypy.root._cpFilterList.append(VPrefix("/vpath"))154 155 156 144 class Image(Test): 157 145 … … 188 176 189 177 def page_yield(self): 190 yield "h ello"178 yield "howdy" 191 179 raise ValueError() 192 180 193 181 def page_streamed(self): 194 yield " hello"182 yield "word up" 195 183 raise ValueError() 196 184 yield "very oops" … … 308 296 def index(self): 309 297 existing = repr(getattr(cherrypy.request, "asdf", None)) 310 cherrypy.request.asdf = " hello"298 cherrypy.request.asdf = "rassfrassin" 311 299 return existing 312 300 … … 510 498 # Test that requests for index methods without a trailing slash 511 499 # get redirected to the same URI path with a trailing slash. 500 # Make sure GET params are preserved. 512 501 self.getPage("/redirect?id=3") 513 502 self.assert_(self.status in ('302 Found', '303 See Other')) … … 565 554 self.assertStatus('303 See Other') 566 555 self.assertInBody('/errpage') 567 568 # Trailing slash redirect on a virtualpath child.569 self.getPage("/vpath/slash")570 self.assertStatus('303 See Other')571 self.assertInBody('/vpath/slash/')572 556 573 557 def testCPFilterList(self): … … 607 591 # started, the status should not change to an error status. 608 592 self.assertStatus("200 OK") 609 self.assertBody(" helloUnrecoverable error in the server.")593 self.assertBody("word upUnrecoverable error in the server.") 610 594 611 595 # No traceback should be present

