Changeset 5176
- Timestamp:
- 08/20/08 13:22:32 (5 months ago)
- Files:
-
- branches/1.0/turbogears/tests/test_testutil.py (modified) (2 diffs)
- branches/1.0/turbogears/testutil.py (modified) (1 diff)
- branches/1.1/turbogears/tests/test_testutil.py (modified) (2 diffs)
- branches/1.1/turbogears/testutil.py (modified) (1 diff)
- branches/1.5/turbogears/tests/test_testutil.py (modified) (2 diffs)
- branches/1.5/turbogears/testutil.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.0/turbogears/tests/test_testutil.py
r3366 r5176 20 20 get_name = turbogears.expose()(get_name) 21 21 22 def get_unicode_name(self): 23 """Return a nonsense string of non-ascii characters""" 24 cherrypy.response.headers['Content-Type'] = 'text/plain; encoding=utf-8' 25 return u'\u1234\u9876\u3456'.encode('utf-8') 26 get_unicode_name = turbogears.expose()(get_unicode_name) 22 27 23 28 def test_browser_session(): … … 40 45 bs2.goto('/get_name') 41 46 assert bs2.response == 'bs2' 47 48 def test_unicode_response(): 49 cherrypy.root = MyRoot() 50 bs = testutil.BrowsingSession() 51 bs.goto('/get_unicode_name') 52 assert bs.response == u'\u1234\u9876\u3456'.encode('utf-8') 53 assert bs.unicode_response == u'\u1234\u9876\u3456' 54 assert type(bs.unicode_response) == unicode branches/1.0/turbogears/testutil.py
r4741 r5176 105 105 headers['Cookie'] = self.cookie.output() 106 106 create_request(*args, **kwargs) 107 # If we were given an encoding in the content type we should use it to 108 # decode the response: 109 ctype_parts = cherrypy.response.headers['Content-Type'].split(';') 110 for parameter in ctype_parts[1:]: 111 attribute, value = parameter.strip().split('=') 112 try: 113 self.unicode_response = cherrypy.response.body[0].decode(value) 114 break 115 except: 116 # If the named encoding doesn't work then it doesn't work. We 117 # just won't create the unicode_response field. 118 pass 107 119 self.response = cherrypy.response.body[0] 108 120 self.status = cherrypy.response.status branches/1.1/turbogears/tests/test_testutil.py
r4695 r5176 29 29 get_name = turbogears.expose()(get_name) 30 30 31 def get_unicode_name(self): 32 """Return a nonsense string of non-ascii characters""" 33 cherrypy.response.headers['Content-Type'] = 'text/plain; encoding=utf-8' 34 return u'\u1234\u9876\u3456'.encode('utf-8') 35 get_unicode_name = turbogears.expose()(get_unicode_name) 31 36 32 37 def test_browser_session(): … … 47 52 bs2.goto('/get_name') 48 53 assert bs2.response == 'bs2' 54 55 def test_unicode_response(): 56 cherrypy.root = MyRoot() 57 bs = testutil.BrowsingSession() 58 bs.goto('/get_unicode_name') 59 assert bs.response == u'\u1234\u9876\u3456'.encode('utf-8') 60 assert bs.unicode_response == u'\u1234\u9876\u3456' 61 assert type(bs.unicode_response) == unicode branches/1.1/turbogears/testutil.py
r5174 r5176 195 195 headers['Cookie'] = self.cookie_encoded 196 196 response = self.app.get(*args, **kwargs) 197 198 # If we were given an encoding in the content type we should use it to 199 # decode the response: 200 ctype_parts = response.headers['Content-Type'].split(';') 201 for parameter in ctype_parts[1:]: 202 attribute, value = parameter.strip().split('=') 203 try: 204 self.unicode_response = response.body.decode(value) 205 break 206 except: 207 # If the named encoding doesn't work then it doesn't work. We 208 # just won't create the unicode_response field. 209 pass 210 197 211 self.response = response.body 198 212 self.status = response.status branches/1.5/turbogears/tests/test_testutil.py
r4962 r5176 28 28 get_name = turbogears.expose()(get_name) 29 29 30 def get_unicode_name(self): 31 """Return a nonsense string of non-ascii characters""" 32 cherrypy.response.headers['Content-Type'] = 'text/plain; encoding=utf-8' 33 return u'\u1234\u9876\u3456'.encode('utf-8') 34 get_unicode_name = turbogears.expose()(get_unicode_name) 30 35 31 36 def test_browser_session(): … … 47 52 bs2.goto('/get_name') 48 53 assert bs2.response == 'bs2' 54 55 def test_unicode_response(): 56 cherrypy.root = MyRoot() 57 bs = testutil.BrowsingSession() 58 bs.goto('/get_unicode_name') 59 assert bs.response == u'\u1234\u9876\u3456'.encode('utf-8') 60 assert bs.unicode_response == u'\u1234\u9876\u3456' 61 assert type(bs.unicode_response) == unicode branches/1.5/turbogears/testutil.py
r4963 r5176 134 134 if self.cookie: 135 135 headers['Cookie'] = self.cookie_encoded 136 136 137 response = self.app.get(path, headers=headers, **kwargs) 138 139 # If we were given an encoding in the content type we should use it to 140 # decode the response: 141 ctype_parts = response.headers['Content-Type'].split(';') 142 for parameter in ctype_parts[1:]: 143 attribute, value = parameter.strip().split('=') 144 try: 145 self.unicode_response = response.body.decode(value) 146 break 147 except: 148 # If the named encoding doesn't work then it doesn't work. We 149 # just won't create the unicode_response field. 150 pass 151 137 152 self.response = response.body 138 153 self.full_response = response