Changeset 1567
- Timestamp:
- 12/28/06 13:26:33
- Files:
-
- branches/cherrypy-2.x/cherrypy/test/helper.py (modified) (2 diffs)
- branches/cherrypy-2.x/cherrypy/test/modpy.py (modified) (2 diffs)
- branches/cherrypy-2.x/cherrypy/test/test.py (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/cherrypy-2.x/cherrypy/test/helper.py
r1499 r1567 99 99 """ 100 100 setConfig(conf) 101 # The Pybots automatic testing system needs the suite to exit 102 # with a non-zero value if there were any problems. 103 # Might as well stick it in the server... :/ 104 cherrypy.server.test_success = True 101 105 cherrypy.server.start_with_callback(_run_test_suite_thread, 102 106 args = (moduleNames, conf), 103 107 server_class = server) 108 if cherrypy.server.test_success: 109 return 0 110 else: 111 return 1 104 112 105 113 def _run_test_suite_thread(moduleNames, conf): … … 118 126 119 127 suite = CPTestLoader.loadTestsFromName(testmod) 120 CPTestRunner.run(suite) 128 result = CPTestRunner.run(suite) 129 cherrypy.server.test_success &= result.wasSuccessful() 121 130 122 131 teardown = getattr(m, "teardown_server", None) branches/cherrypy-2.x/cherrypy/test/modpy.py
r1498 r1567 114 114 import webtest 115 115 webtest.WebCase.PORT = self.port 116 webtest.WebCase.interactive = self.interactive 116 117 print 117 118 print "Running tests:", self.server … … 121 122 # must run the setup_server() function for the test. 122 123 # Then our process can run the actual test. 124 test_success = True 123 125 for testmod in self.tests: 124 126 try: 125 127 start(testmod, self.port) 126 128 suite = webtest.ReloadingTestLoader().loadTestsFromName(testmod) 127 webtest.TerseTestRunner(verbosity=2).run(suite) 129 result = webtest.TerseTestRunner(verbosity=2).run(suite) 130 test_success &= result.wasSuccessful() 128 131 finally: 129 132 stop() 133 if test_success: 134 return 0 135 else: 136 return 1 130 137 131 138 branches/cherrypy-2.x/cherrypy/test/test.py
r1523 r1567 20 20 """A test harness for the CherryPy framework and CherryPy applications.""" 21 21 22 def __init__(self, tests=None, server=None, protocol="HTTP/1.1", port=8000): 22 def __init__(self, tests=None, server=None, protocol="HTTP/1.1", 23 port=8000, interactive=True): 23 24 """Constructor to populate the TestHarness instance. 24 25 … … 27 28 self.protocol = protocol 28 29 self.port = port 30 self.interactive = interactive 29 31 self.server = server 30 32 self.tests = tests or [] … … 50 52 51 53 baseconf['server.protocol_version'] = self.protocol 52 self._run(baseconf)54 return self._run(baseconf) 53 55 54 56 def _run(self, conf): … … 61 63 import helper 62 64 webtest.WebCase.PORT = self.port 65 webtest.WebCase.interactive = self.interactive 63 66 print 64 67 print "Running tests:", self.server 65 helper.run_test_suite(self.tests, self.server, conf)68 return helper.run_test_suite(self.tests, self.server, conf) 66 69 67 70 … … 73 76 default_server = "wsgi" 74 77 port = 8080 78 interactive = True 75 79 76 80 def __init__(self, available_tests, args=sys.argv[1:]): … … 88 92 self.protocol = "HTTP/1.1" 89 93 90 longopts = ['cover', 'profile', ' 1.1', 'help', 'basedir=', 'port=',91 ' server=']94 longopts = ['cover', 'profile', 'dumb', '1.1', 'help', 95 'basedir=', 'port=', 'server='] 92 96 longopts.extend(self.available_tests) 93 97 try: … … 108 112 elif o == "--profile": 109 113 self.profile = True 114 elif o == "--dumb": 115 self.interactive = False 110 116 elif o == "--1.0": 111 117 self.protocol = "HTTP/1.0" … … 140 146 print """CherryPy Test Program 141 147 Usage: 142 test.py --server=* --port=%s --1.1 --cover --basedir=path --profile -- tests**148 test.py --server=* --port=%s --1.1 --cover --basedir=path --profile --dumb --tests** 143 149 144 150 """ % self.__class__.port … … 152 158 print """ 153 159 154 --port=<int>: use a port other than the default (%s) 155 --1.1: use HTTP/1.1 servers instead of default HTTP/1.0 156 157 --cover: turn on code-coverage tool160 --port=<int>: use a port other than the default (%s). 161 --1.1: use HTTP/1.1 servers instead of default HTTP/1.0. 162 163 --cover: turn on the code-coverage tool. 158 164 --basedir=path: display coverage stats for some path other than cherrypy. 159 165 160 --profile: turn on profiling tool 166 --profile: turn on the profiling tool. 167 --dumb: turn off the interactive output features. 161 168 """ % self.__class__.port 162 169 … … 260 267 if self.server == 'modpy': 261 268 import modpy 262 modpy.ModPythonTestHarness(self.tests, self.server, 263 self.protocol, self.port).run(conf) 269 h = modpy.ModPythonTestHarness(self.tests, self.server, 270 self.protocol, self.port, 271 self.interactive) 264 272 else: 265 TestHarness(self.tests, self.server, 266 self.protocol, self.port).run(conf) 273 h = TestHarness(self.tests, self.server, 274 self.protocol, self.port, 275 self.interactive) 276 277 success = h.run(conf) 267 278 268 279 if self.profile: … … 274 285 if self.cover: 275 286 self.stop_coverage() 287 288 return success 276 289 277 290 … … 312 325 'test_wsgiapp_filter', 313 326 ] 314 CommandLineParser(testList).run() 315 316 print 317 raw_input('hit enter') 327 clp = CommandLineParser(testList) 328 success = clp.run() 329 if clp.interactive: 330 print 331 raw_input('hit enter') 332 sys.exit(success) 318 333 319 334

