Changeset 2438
- Timestamp:
- 06/14/09 18:00:03
- Files:
-
- branches/python3/cherrypy/__init__.py (modified) (1 diff)
- branches/python3/cherrypy/_cpmodpy.py (modified) (2 diffs)
- branches/python3/cherrypy/_cpwsgi.py (modified) (2 diffs)
- branches/python3/cherrypy/lib/encoding.py (modified) (3 diffs)
- branches/python3/cherrypy/lib/profiler.py (modified) (2 diffs)
- branches/python3/cherrypy/lib/tidy.py (modified) (1 diff)
- branches/python3/cherrypy/py3util.py (deleted)
- branches/python3/cherrypy/test/benchmark.py (modified) (6 diffs)
- branches/python3/cherrypy/test/helper.py (modified) (2 diffs)
- branches/python3/cherrypy/test/logtest.py (modified) (4 diffs)
- branches/python3/cherrypy/test/modfcgid.py (modified) (1 diff)
- branches/python3/cherrypy/test/modpy.py (modified) (1 diff)
- branches/python3/cherrypy/test/modwsgi.py (modified) (1 diff)
- branches/python3/cherrypy/test/test.py (modified) (11 diffs)
- branches/python3/cherrypy/test/test_config.py (modified) (1 diff)
- branches/python3/cherrypy/test/test_config_server.py (modified) (2 diffs)
- branches/python3/cherrypy/test/test_conn.py (modified) (8 diffs)
- branches/python3/cherrypy/test/test_encoding.py (modified) (2 diffs)
- branches/python3/cherrypy/test/test_http.py (modified) (2 diffs)
- branches/python3/cherrypy/test/test_request_obj.py (modified) (1 diff)
- branches/python3/cherrypy/test/test_session.py (modified) (4 diffs)
- branches/python3/cherrypy/test/test_states.py (modified) (7 diffs)
- branches/python3/cherrypy/test/test_static.py (modified) (2 diffs)
- branches/python3/cherrypy/test/test_tidy.py (modified) (1 diff)
- branches/python3/cherrypy/test/test_tools.py (modified) (6 diffs)
- branches/python3/cherrypy/test/test_wsgi_ns.py (modified) (1 diff)
- branches/python3/cherrypy/test/test_wsgi_vhost.py (modified) (1 diff)
- branches/python3/cherrypy/test/test_wsgiapps.py (modified) (3 diffs)
- branches/python3/cherrypy/test/webtest.py (modified) (5 diffs)
- branches/python3/cherrypy/tutorial/bonus-sqlobject.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/python3/cherrypy/__init__.py
r2422 r2438 548 548 return newurl 549 549 550 from cherrypy.py3util import py3print551 550 552 551 # import _cpconfig last so it can reference other top-level objects branches/python3/cherrypy/_cpmodpy.py
r2183 r2438 57 57 58 58 import logging 59 import io 59 from io import BytesIO 60 60 61 61 import cherrypy … … 220 220 path = ir.path 221 221 qs = ir.query_string 222 rfile = io.StringIO()222 rfile = BytesIO() 223 223 224 224 send_response(req, response.status, response.header_list, branches/python3/cherrypy/_cpwsgi.py
r2433 r2438 4 4 5 5 import cherrypy as _cherrypy 6 from cherrypy.py3util import StringIO6 from io import BytesIO 7 7 from cherrypy import _cperror 8 8 from cherrypy.lib import httputil … … 151 151 env['PATH_INFO'] = path 152 152 env['QUERY_STRING'] = query_string 153 env['wsgi.input'] = StringIO()153 env['wsgi.input'] = BytesIO() 154 154 env['CONTENT_LENGTH'] = "0" 155 155 branches/python3/cherrypy/lib/encoding.py
r2420 r2438 1 import io 1 from io import IOBase, BytesIO 2 2 import struct 3 3 import time … … 145 145 # [''] doesn't evaluate to False, so replace it with []. 146 146 self.body = [] 147 elif isinstance(self.body, io.IOBase):147 elif isinstance(self.body, IOBase): 148 148 self.body = file_generator(self.body) 149 149 elif self.body is None: … … 194 194 def decompress(body): 195 195 import gzip 196 import io 197 198 zbuf = io.BytesIO() 196 197 zbuf = BytesIO() 199 198 zbuf.write(body) 200 199 zbuf.seek(0) branches/python3/cherrypy/lib/profiler.py
r2395 r2438 55 55 import sys 56 56 57 from cherrypy.py3utilimport StringIO57 from io import StringIO 58 58 59 59 _count = 0 … … 86 86 """stats(index) -> output of print_stats() for the given profile.""" 87 87 sio = StringIO() 88 if sys.version_info >= (2, 5): 89 s = pstats.Stats(os.path.join(self.path, filename), stream=sio) 90 s.strip_dirs() 91 s.sort_stats(sortby) 92 s.print_stats() 93 else: 94 # pstats.Stats before Python 2.5 didn't take a 'stream' arg, 95 # but just printed to stdout. So re-route stdout. 96 s = pstats.Stats(os.path.join(self.path, filename)) 97 s.strip_dirs() 98 s.sort_stats(sortby) 99 oldout = sys.stdout 100 try: 101 sys.stdout = sio 102 s.print_stats() 103 finally: 104 sys.stdout = oldout 88 s = pstats.Stats(os.path.join(self.path, filename), stream=sio) 89 s.strip_dirs() 90 s.sort_stats(sortby) 91 s.print_stats() 105 92 response = sio.getvalue() 106 93 sio.close() branches/python3/cherrypy/lib/tidy.py
r2395 r2438 3 3 import cgi 4 4 import os 5 from cherrypy.py3utilimport StringIO5 from io import StringIO 6 6 import traceback 7 7 branches/python3/cherrypy/test/benchmark.py
r2390 r2438 218 218 self.output = _cpmodpy.read_process(AB_PATH or "ab", self.args()) 219 219 except: 220 cherrypy.py3print(_cperror.format_exc())220 print(_cperror.format_exc()) 221 221 raise 222 222 … … 273 273 widths.append(max(lengths)) 274 274 for row in rows: 275 cherrypy.py3print()275 print("") 276 276 for i, val in enumerate(row): 277 cherrypy.py3print(str(val).rjust(widths[i]), "|", end=' ')278 cherrypy.py3print()277 print(str(val).rjust(widths[i]), "|", end=' ') 278 print("") 279 279 280 280 281 281 def run_standard_benchmarks(): 282 cherrypy.py3print()283 cherrypy.py3print("Client Thread Report (1000 requests, 14 byte response body, "282 print("") 283 print("Client Thread Report (1000 requests, 14 byte response body, " 284 284 "%s server threads):" % cherrypy.server.thread_pool) 285 285 print_report(thread_report()) 286 286 287 cherrypy.py3print()288 cherrypy.py3print("Client Thread Report (1000 requests, 14 bytes via staticdir, "287 print("") 288 print("Client Thread Report (1000 requests, 14 bytes via staticdir, " 289 289 "%s server threads):" % cherrypy.server.thread_pool) 290 290 print_report(thread_report("%s/static/index.html" % SCRIPT_NAME)) 291 291 292 cherrypy.py3print()293 cherrypy.py3print("Size Report (1000 requests, 50 client threads, "292 print("") 293 print("Size Report (1000 requests, 50 client threads, " 294 294 "%s server threads):" % cherrypy.server.thread_pool) 295 295 print_report(size_report()) … … 316 316 317 317 def run_modpython(use_wsgi=False): 318 cherrypy.py3print("Starting mod_python...")318 print("Starting mod_python...") 319 319 pyopts = [] 320 320 … … 351 351 opts = dict(switches) 352 352 except getopt.GetoptError: 353 cherrypy.py3print(__doc__)353 print(__doc__) 354 354 sys.exit(2) 355 355 356 356 if "--help" in opts: 357 cherrypy.py3print(__doc__)357 print(__doc__) 358 358 sys.exit(0) 359 359 … … 366 366 def run(): 367 367 port = cherrypy.server.socket_port 368 cherrypy.py3print("You may now open http://127.0.0.1:%s%s/" %368 print("You may now open http://127.0.0.1:%s%s/" % 369 369 (port, SCRIPT_NAME)) 370 370 371 371 if "--null" in opts: 372 cherrypy.py3print("Using null Request object")372 print("Using null Request object") 373 373 else: 374 374 def run(): 375 375 end = time.time() - start 376 cherrypy.py3print("Started in %s seconds" % end)376 print("Started in %s seconds" % end) 377 377 if "--null" in opts: 378 cherrypy.py3print("\nUsing null Request object")378 print("\nUsing null Request object") 379 379 try: 380 380 run_standard_benchmarks() … … 382 382 cherrypy.engine.exit() 383 383 384 cherrypy.py3print("Starting CherryPy app server...")384 print("Starting CherryPy app server...") 385 385 386 386 class NullWriter(object): branches/python3/cherrypy/test/helper.py
r2393 r2438 57 57 url = httputil.urljoin(self.script_name, url) 58 58 return webtest.WebCase.getPage(self, url, headers, method, body, protocol) 59 60 def skip(self, msg='skipped '): 61 sys.stdout.write(msg) 59 62 60 63 def assertErrorPage(self, status, message=None, pattern=''): … … 194 197 ssl = "" 195 198 199 conf = self.config_template % { 200 'host': self.host, 201 'port': self.port, 202 'error_log': self.error_log, 203 'access_log': self.access_log, 204 'ssl': ssl, 205 'extra': extra, 206 } 196 207 f = open(self.config_file, 'wb') 197 f.write(bytes(self.config_template % 198 {'host': self.host, 199 'port': self.port, 200 'error_log': self.error_log, 201 'access_log': self.access_log, 202 'ssl': ssl, 203 'extra': extra, 204 }, 'utf8')) 208 f.write(bytes(conf, 'utf8')) 205 209 f.close() 206 210 branches/python3/cherrypy/test/logtest.py
r2430 r2438 44 44 45 45 def _handleLogError(self, msg, data, marker, pattern): 46 cherrypy.py3print()47 cherrypy.py3print(" ERROR:",msg)46 print("") 47 print(" ERROR: %s" % msg) 48 48 49 49 if not self.interactive: … … 51 51 52 52 p = " Show: [L]og [M]arker [P]attern; [I]gnore, [R]aise, or sys.e[X]it >> " 53 cherrypy.py3print(p, end=' ')53 print(p, end=' ') 54 54 # ARGH 55 55 sys.stdout.flush() … … 58 58 if i not in "MPLIRX": 59 59 continue 60 cherrypy.py3print(i.upper()) # Also prints new line60 print(i.upper()) # Also prints new line 61 61 if i == "L": 62 62 for x, line in enumerate(data): 63 63 if (x + 1) % self.console_height == 0: 64 64 # The \r and comma should make the next line overwrite 65 cherrypy.py3print("<-- More -->\r", end=' ')65 print("<-- More -->\r", end=' ') 66 66 m = getchar().lower() 67 67 # Erase our "More" prompt 68 cherrypy.py3print(" \r", end=' ')68 print(" \r", end=' ') 69 69 if m == "q": 70 70 break 71 cherrypy.py3print(line.rstrip())71 print(line.rstrip()) 72 72 elif i == "M": 73 cherrypy.py3print(repr(marker or self.lastmarker))73 print(repr(marker or self.lastmarker)) 74 74 elif i == "P": 75 cherrypy.py3print(repr(pattern))75 print(repr(pattern)) 76 76 elif i == "I": 77 77 # return without raising the normal exception … … 81 81 elif i == "X": 82 82 self.exit() 83 cherrypy.py3print(p, end=' ')83 print(p, end=' ') 84 84 85 85 def exit(self): branches/python3/cherrypy/test/modfcgid.py
r2390 r2438 111 111 result = read_process(APACHE_PATH, "-k start -f %s" % fcgiconf) 112 112 if result: 113 cherrypy.py3print(result)113 print(result) 114 114 115 115 def stop(self): branches/python3/cherrypy/test/modpy.py
r2390 r2438 117 117 result = read_process(APACHE_PATH, "-k start -f %s" % mpconf) 118 118 if result: 119 cherrypy.py3print(result)119 print(result) 120 120 121 121 def stop(self): branches/python3/cherrypy/test/modwsgi.py
r2390 r2438 116 116 result = read_process(APACHE_PATH, "-k start -f %s" % mpconf) 117 117 if result: 118 cherrypy.py3print(result)118 print(result) 119 119 120 120 # Make a request so mod_wsgi starts up our app. branches/python3/cherrypy/test/test.py
r2420 r2438 41 41 import cherrypy 42 42 v = sys.version.split()[0] 43 cherrypy.py3print("Python version used to run this test script:",v)44 cherrypy.py3print("CherryPy version",cherrypy.__version__)43 print("Python version used to run this test script: %s" % v) 44 print("CherryPy version: %s" % cherrypy.__version__) 45 45 if self.scheme == "https": 46 ssl = " (ssl)"46 ssl = " (ssl)" 47 47 else: 48 48 ssl = "" 49 cherrypy.py3print("HTTP server version", self.protocol, ssl)50 cherrypy.py3print("PID:",os.getpid())51 cherrypy.py3print()49 print("HTTP server version: %s%s" % (self.protocol, ssl)) 50 print("PID: %s" % os.getpid()) 51 print("") 52 52 53 53 if isinstance(conf, str): … … 76 76 if self.scheme == "https": 77 77 webtest.WebCase.HTTP_CONN = HTTPSConnection 78 cherrypy.py3print()79 cherrypy.py3print("Running tests:",self.server)78 print("") 79 print("Running tests: %s" % self.server) 80 80 81 81 return helper.run_test_suite(self.tests, baseconf, self.server) … … 246 246 if self.cover and self.profile: 247 247 # Print error message and exit 248 cherrypy.py3print('Error: you cannot run the profiler and the '248 print('Error: you cannot run the profiler and the ' 249 249 'coverage tool at the same time.') 250 250 sys.exit(2) … … 260 260 261 261 import cherrypy 262 cherrypy.py3print("""CherryPy Test Program262 print("""CherryPy Test Program 263 263 Usage: 264 264 test.py --help --server=* --host=%s --port=%s --1.0 --ssl --cover … … 266 266 267 267 """ % (self.__class__.host, self.__class__.port)) 268 cherrypy.py3print(' * servers:')268 print(' * servers:') 269 269 for name, val in self.available_servers.items(): 270 270 if name == self.default_server: 271 cherrypy.py3print(' --server=%s: %s (default)' % (name, val))271 print(' --server=%s: %s (default)' % (name, val)) 272 272 else: 273 cherrypy.py3print(' --server=%s: %s' % (name, val))274 275 cherrypy.py3print("""273 print(' --server=%s: %s' % (name, val)) 274 275 print(""" 276 276 277 277 --host=<name or IP addr>: use a host other than the default (%s). … … 289 289 """ % (self.__class__.host, self.__class__.port)) 290 290 291 cherrypy.py3print(' ** tests:')291 print(' ** tests:') 292 292 for name in self.available_tests: 293 cherrypy.py3print(' --' + name)293 print(' --' + name) 294 294 295 295 def start_coverage(self): … … 328 328 self.coverage.save() 329 329 self.report_coverage() 330 cherrypy.py3print("run cherrypy/lib/covercp.py as a script to serve "330 print("run cherrypy/lib/covercp.py as a script to serve " 331 331 "coverage results on port 8080") 332 332 … … 351 351 total_executed = 0 352 352 353 cherrypy.py3print()354 cherrypy.py3print("CODE COVERAGE (this might take a while)", end=' ')353 print("") 354 sys.stdout.write("CODE COVERAGE (this might take a while)") 355 355 for morf in morfs: 356 356 sys.stdout.write(".") … … 375 375 pc = 100.0 * total_executed / total_statements 376 376 377 cherrypy.py3print("\nTotal: %s Covered: %s Percent: %2d%%"377 print("\nTotal: %s Covered: %s Percent: %2d%%" 378 378 % (total_statements, total_executed, pc)) 379 379 … … 425 425 426 426 if self.profile: 427 cherrypy.py3print()428 cherrypy.py3print("run /cherrypy/lib/profiler.py as a script to serve "427 print("") 428 print("run /cherrypy/lib/profiler.py as a script to serve " 429 429 "profiling results on port 8080") 430 430 … … 497 497 import cherrypy 498 498 if clp.interactive: 499 cherrypy.py3print()499 print("") 500 500 input('hit enter') 501 501 sys.exit(success) branches/python3/cherrypy/test/test_config.py
r2395 r2438 7 7 localDir = os.path.join(os.getcwd(), os.path.dirname(__file__)) 8 8 9 from io import StringIO 10 import unittest 11 9 12 import cherrypy 10 from cherrypy.py3util import StringIO11 import unittest12 13 13 14 def setup_server(): branches/python3/cherrypy/test/test_config_server.py
r2412 r2438 79 79 def testMaxRequestSizePerHandler(self): 80 80 if getattr(cherrypy.server, "using_apache", False): 81 cherrypy.py3print("skipped due to known Apache differences...", end=' ') 82 return 81 return self.skip("skipped due to known Apache differences... ") 83 82 84 83 self.getPage('/tinyupload?maxlen=100', method="POST", body="x" * 100) … … 90 89 def testMaxRequestSize(self): 91 90 if getattr(cherrypy.server, "using_apache", False): 92 cherrypy.py3print("skipped due to known Apache differences...", end=' ') 93 return 91 return self.skip("skipped due to known Apache differences... ") 94 92 95 93 for size in (500, 5000, 50000): branches/python3/cherrypy/test/test_conn.py
r2412 r2438 93 93 def test_HTTP11(self): 94 94 if cherrypy.server.protocol_version != "HTTP/1.1": 95 cherrypy.py3print("skipped ", end=' ') 96 return 95 return self.skip() 97 96 98 97 self.PROTOCOL = "HTTP/1.1" … … 250 249 # the server will close the conn with a 408. 251 250 if cherrypy.server.protocol_version != "HTTP/1.1": 252 cherrypy.py3print("skipped ", end=' ') 253 return 251 return self.skip() 254 252 255 253 self.PROTOCOL = "HTTP/1.1" … … 291 289 # the server will close the conn without 408. 292 290 if cherrypy.server.protocol_version != "HTTP/1.1": 293 cherrypy.py3print("skipped ", end=' ') 294 return 291 return self.skip() 295 292 296 293 self.PROTOCOL = "HTTP/1.1" … … 387 384 def test_HTTP11_pipelining(self): 388 385 if cherrypy.server.protocol_version != "HTTP/1.1": 389 cherrypy.py3print("skipped ", end=' ') 390 return 386 return self.skip() 391 387 392 388 self.PROTOCOL = "HTTP/1.1" … … 425 421 def test_100_Continue(self): 426 422 if cherrypy.server.protocol_version != "HTTP/1.1": 427 cherrypy.py3print("skipped ", end=' ') 428 return 423 return self.skip() 429 424 430 425 self.PROTOCOL = "HTTP/1.1" … … 480 475 def test_readall_or_close(self): 481 476 if cherrypy.server.protocol_version != "HTTP/1.1": 482 cherrypy.py3print("skipped ", end=' ') 483 return 477 return self.skip() 484 478 485 479 self.PROTOCOL = "HTTP/1.1" … … 552 546 def test_No_Message_Body(self): 553 547 if cherrypy.server.protocol_version != "HTTP/1.1": 554 cherrypy.py3print("skipped ", end=' ') 555 return 548 return self.skip() 556 549 557 550 self.PROTOCOL = "HTTP/1.1" … … 582 575 def test_Chunked_Encoding(self): 583 576 if cherrypy.server.protocol_version != "HTTP/1.1": 584 cherrypy.py3print("skipped ", end=' ') 585 return 577 return self.skip() 586 578 587 579 if (hasattr(self, 'harness') and 588 580 "modpython" in self.harness.__class__.__name__.lower()): 589 581 # mod_python forbids chunked encoding 590 cherrypy.py3print("skipped ", end=' ') 591 return 582 return self.skip() 592 583 593 584 self.PROTOCOL = "HTTP/1.1" branches/python3/cherrypy/test/test_encoding.py
r2403 r2438 2 2 test.prefer_parent_path() 3 3 4 import gzip 5 from io import BytesIO 6 from http.client import IncompleteRead 4 7 import sys 5 import gzip, io 6 from http.client import IncompleteRead 8 7 9 import cherrypy 10 8 11 europoundUnicode = '\x80\xa3' 9 12 sing = "\u6bdb\u6cfd\u4e1c: Sing, Little Birdie?" … … 126 129 127 130 def testGzip(self): 128 zbuf = io.BytesIO()131 zbuf = BytesIO() 129 132 zfile = gzip.GzipFile(mode='wb', fileobj=zbuf, compresslevel=9) 130 133 zfile.write("Hello, world") branches/python3/cherrypy/test/test_http.py
r2390 r2438 131 131 def test_malformed_request_line(self): 132 132 if getattr(cherrypy.server, "using_apache", False): 133 cherrypy.py3print("skipped due to known Apache differences...", end=' ') 134 return 133 return self.skip("skipped due to known Apache differences...") 135 134 136 135 # Test missing version in Request-Line … … 149 148 def test_http_over_https(self): 150 149 if self.scheme != 'https': 151 cherrypy.py3print("skipped (not running HTTPS)...", end=' ') 152 return 150 return self.skip("skipped (not running HTTPS)... ") 153 151 154 152 # Try connecting without SSL. branches/python3/cherrypy/test/test_request_obj.py
r2411 r2438 708 708 def test_CONNECT_method(self): 709 709 if getattr(cherrypy.server, "using_apache", False): 710 cherrypy.py3print("skipped due to known Apache differences...", end=' ') 711 return 710 return self.skip("skipped due to known Apache differences... ") 712 711 713 712 self.getPage("/method/", method="CONNECT") branches/python3/cherrypy/test/test_session.py
r2436 r2438 243 243 data_dict[index] = max(data_dict[index], int(body)) 244 244 # Uncomment the following line to prove threads overlap. 245 ## cherrypy.py3print(index, end=' ')245 ## print(index, end=' ') 246 246 247 247 # Start <request_count> requests from each of … … 261 261 262 262 for e in errors: 263 cherrypy.py3print(e)263 print(e) 264 264 self.assertEqual(hitcount, expected) 265 265 … … 376 376 377 377 def test(self): 378 cherrypy.py3print("skipped", end=' ')378 return self.skip("memcached not reachable ") 379 379 else: 380 380 class MemcachedSessionTest(helper.CPWebCase): … … 423 423 self.getPage("/", cookies) 424 424 # Uncomment the following line to prove threads overlap. 425 ## cherrypy.py3print(index, end=' ')425 ## print(index, end=' ') 426 426 if not self.body.isdigit(): 427 427 self.fail(self.body) branches/python3/cherrypy/test/test_states.py
r2390 r2438 210 210 pass 211 211 else: 212 cherrypy.py3print(self.body)212 print(self.body) 213 213 self.fail("AssertionError: BadStatusLine not raised") 214 214 … … 231 231 # request.close is called async. 232 232 while engine.timeout_monitor.servings: 233 cherrypy.py3print(".", end=' ')233 print(".", end=' ') 234 234 time.sleep(0.01) 235 235 … … 296 296 def test_daemonize(self): 297 297 if os.name not in ['posix']: 298 cherrypy.py3print("skipped (not on posix) ", end=' ') 299 return 298 return self.skip("skipped (not on posix) ") 300 299 self.HOST = '127.0.0.1' 301 300 self.PORT = 8081 … … 334 333 from signal import SIGHUP 335 334 except ImportError: 336 cherrypy.py3print("skipped (no SIGHUP) ", end=' ') 337 return 335 return self.skip("skipped (no SIGHUP) ") 338 336 339 337 # Spawn the process. … … 352 350 from signal import SIGHUP 353 351 except ImportError: 354 cherrypy.py3print("skipped (no SIGHUP) ", end=' ') 355 return 352 return self.skip("skipped (no SIGHUP) ") 356 353 357 354 if os.name not in ['posix']: 358 cherrypy.py3print("skipped (not on posix) ", end=' ') 359 return 355 return self.skip("skipped (not on posix) ") 360 356 361 357 # Spawn the process and wait, when this returns, the original process … … 388 384 from signal import SIGTERM 389 385 except ImportError: 390 cherrypy.py3print("skipped (no SIGTERM) ", end=' ') 391 return 386 return self.skip("skipped (no SIGTERM) ") 392 387 393 388 try: 394 389 from os import kill 395 390 except ImportError: 396 cherrypy.py3print("skipped (no os.kill) ", end=' ') 397 return 391 return self.skip("skipped (no os.kill) ") 398 392 399 393 # Spawn a normal, undaemonized process. … … 423 417 from signal import SIGTERM 424 418 except ImportError: 425 cherrypy.py3print("skipped (no SIGTERM) ", end=' ') 426 return 419 return self.skip("skipped (no SIGTERM) ") 427 420 428 421 try: 429 422 from os import kill 430 423 except ImportError: 431 cherrypy.py3print("skipped (no os.kill) ", end=' ') 432 return 424 return self.skip("skipped (no os.kill) ") 433 425 434 426 # Spawn a normal, undaemonized process. branches/python3/cherrypy/test/test_static.py
r2420 r2438 211 211 def test_file_stream(self): 212 212 if cherrypy.server.protocol_version != "HTTP/1.1": 213 cherrypy.py3print("skipped ", end=' ') 214 return 213 return self.skip() 215 214 216 215 self.PROTOCOL = "HTTP/1.1" … … 250 249 def test_file_stream_deadlock(self): 251 250 if cherrypy.server.protocol_version != "HTTP/1.1": 252 cherrypy.py3print("skipped ", end=' ') 253 return 251 return self.skip() 254 252 255 253 self.PROTOCOL = "HTTP/1.1" branches/python3/cherrypy/test/test_tidy.py
r2390 r2438 50 50 def test_Tidy_Tool(self): 51 51 if not os.path.exists(tidy_path) and not os.path.exists(tidy_path + ".exe"): 52 cherrypy.py3print("skipped (tidy not found) ", end=' ') 53 return 52 return self.skip("skipped (tidy not found) ") 54 53 55 54 self.getPage('/validhtml') branches/python3/cherrypy/test/test_tools.py
r2390 r2438 2 2 3 3 import gzip 4 import io 4 from io import BytesIO 5 5 import sys 6 6 from http.client import IncompleteRead … … 95 95 96 96 def stream_handler(next_handler, *args, **kwargs): 97 cherrypy.response.output = o = io.BytesIO()97 cherrypy.response.output = o = BytesIO() 98 98 try: 99 99 response = next_handler(*args, **kwargs) … … 328 328 old_timeout = httpserver.timeout 329 329 except (AttributeError, IndexError): 330 cherrypy.py3print("skipped ", end=' ') 331 return 330 return self.skip() 332 331 333 332 try: … … 368 367 def testCombinedTools(self): 369 368 expectedResult = ("Hello,world" + europoundUnicode).encode('utf-8') 370 zbuf = io.BytesIO()369 zbuf = BytesIO() 371 370 zfile = gzip.GzipFile(mode='wb', fileobj=zbuf, compresslevel=9) 372 371 zfile.write(expectedResult) … … 377 376 self.assertInBody(zbuf.getvalue()[:3]) 378 377 379 zbuf = io.BytesIO()378 zbuf = BytesIO() 380 379 zfile = gzip.GzipFile(mode='wb', fileobj=zbuf, compresslevel=6) 381 380 zfile.write(expectedResult) … … 407 406 def testToolWithConfig(self): 408 407 if not sys.version_info >= (2, 5): 409 cherrypy.py3print("skipped (Python 2.5+ only)", end=' ') 410 return 408 return self.skip("skipped (Python 2.5+ only)") 411 409 412 410 self.getPage('/tooldecs/blah') branches/python3/cherrypy/test/test_wsgi_ns.py
r2390 r2438 77 77 def test_pipeline(self): 78 78 if not cherrypy.server.httpserver: 79 cherrypy.py3print("skipped ", end=' ') 80 return 79 return self.skip() 81 80 82 81 self.getPage("/") branches/python3/cherrypy/test/test_wsgi_vhost.py
r2390 r2438 34 34 def test_welcome(self): 35 35 if not cherrypy.server.using_wsgi: 36 cherrypy.py3print("skipped (not using WSGI)...", end=' ') 37 return 36 return self.skip("skipped (not using WSGI)... ") 38 37 39 38 for year in range(1997, 2008): branches/python3/cherrypy/test/test_wsgiapps.py
r2430 r2438 90 90 import cherrypy 91 91 if not cherrypy.server.using_wsgi: 92 cherrypy.py3print("skipped (not using WSGI)...", end=' ') 93 return 92 return self.skip("skipped (not using WSGI)... ") 94 93 self.getPage("/hosted/app1") 95 94 self.assertHeader("Content-Type", "text/plain") … … 99 98 import cherrypy 100 99 if not cherrypy.server.using_wsgi: 101 cherrypy.py3print("skipped (not using WSGI)...", end=' ') 102 return 100 return self.skip("skipped (not using WSGI)... ") 103 101 self.getPage("/hosted/app2/") 104 102 body = list("I'm a regular CherryPy page handler!") … … 110 108 import cherrypy 111 109 if not cherrypy.server.using_wsgi: 112 cherrypy.py3print("skipped (not using WSGI)...", end=' ') 113 return 110 return self.skip("skipped (not using WSGI)... ") 114 111 self.getPage("/hosted/app3") 115 112 self.assertHeader("Content-Type", "text/plain") branches/python3/cherrypy/test/webtest.py
r2415 r2438 252 252 def _handlewebError(self, msg): 253 253 import cherrypy 254 cherrypy.py3print()255 cherrypy.py3print(" ERROR:",msg)254 print("") 255 print(" ERROR: %s" % msg) 256 256 257 257 if not self.interactive: … … 259 259 260 260 p = " Show: [B]ody [H]eaders [S]tatus [U]RL; [I]gnore, [R]aise, or sys.e[X]it >> " 261 cherrypy.py3print(p, end=' ')261 print(p, end=' ') 262 262 # ARGH! 263 263 sys.stdout.flush() … … 268 268 if i not in "BHSUIRX": 269 269 continue 270 cherrypy.py3print(i.upper()) # Also prints new line270 print(i.upper()) # Also prints new line 271 271 if i == "B": 272 272 for x, line in enumerate(self.body.splitlines()): 273 273 if (x + 1) % self.console_height == 0: 274 274 # The \r and comma should make the next line overwrite 275 cherrypy.py3print("<-- More -->\r", end=' ')275 print("<-- More -->\r", end=' ') 276 276 m = getchar().lower() 277 277 # Erase our "More" prompt 278 cherrypy.py3print(" \r", end=' ')278 print(" \r", end=' ') 279 279 if m == "q": 280 280 break 281 cherrypy.py3print(line)281 print(line) 282 282 elif i == "H": 283 283 pprint.pprint(self.headers) 284 284 elif i == "S": 285 cherrypy.py3print(self.status)285 print(self.status) 286 286 elif i == "U": 287 cherrypy.py3print(self.url)287 print(self.url) 288 288 elif i == "I": 289 289 # return without raising the normal exception … … 293 293 elif i == "X": 294 294 self.exit() 295 cherrypy.py3print(p, end=' ')295 print(p, end=' ') 296 296 # ARGH 297 297 sys.stdout.flush() … … 605 605 else: 606 606 ServerError.on = True 607 cherrypy.py3print()608 cherrypy.py3print("".join(traceback.format_exception(*exc)))607 print("") 608 print("".join(traceback.format_exception(*exc))) 609 609 return True 610 610 branches/python3/cherrypy/tutorial/bonus-sqlobject.py
r2390 r2438 164 164 165 165 166 cherrypy.py3print("If you're running this application for the first time, please go to http://localhost:8080/reset once in order to create the database!")166 print("If you're running this application for the first time, please go to http://localhost:8080/reset once in order to create the database!") 167 167 168 168 cherrypy.quickstart(ContactManager())

