##// END OF EJS Templates
run-tests: support setUp() and tearDown() in TestCase wrapper...
Gregory Szorc -
r21446:9a3b4f79 default
parent child Browse files
Show More
@@ -377,6 +377,9 b' class Test(object):'
377 377 if self._threadtmp and not self._options.keep_tmpdir:
378 378 shutil.rmtree(self._threadtmp, True)
379 379
380 def setUp(self):
381 """Tasks to perform before run()."""
382
380 383 def run(self):
381 384 """Run this test instance.
382 385
@@ -506,6 +509,9 b' class Test(object):'
506 509
507 510 return res
508 511
512 def tearDown(self):
513 """Tasks to perform after run()."""
514
509 515 def _run(self, testtmp, replacements, env):
510 516 # This should be implemented in child classes to run tests.
511 517 return self._skip('unknown test type')
@@ -1352,6 +1358,15 b' class TestRunner(object):'
1352 1358 # with it.
1353 1359 def run(self, result):
1354 1360 try:
1361 t.setUp()
1362 except (KeyboardInterrupt, SystemExit):
1363 raise
1364 except Exception:
1365 result.addError(self, sys.exc_info())
1366 return
1367
1368 success = False
1369 try:
1355 1370 self.runTest()
1356 1371 except KeyboardInterrupt:
1357 1372 raise
@@ -1366,6 +1381,17 b' class TestRunner(object):'
1366 1381 except Exception:
1367 1382 result.addError(self, sys.exc_info())
1368 1383 else:
1384 success = True
1385
1386 try:
1387 t.tearDown()
1388 except (KeyboardInterrupt, SystemExit):
1389 raise
1390 except Exception:
1391 result.addError(self, sys.exc_info())
1392 success = False
1393
1394 if success:
1369 1395 result.addSuccess(self)
1370 1396
1371 1397 def runTest(self):
General Comments 0
You need to be logged in to leave comments. Login now