Show More
@@ -377,6 +377,9 b' class Test(object):' | |||||
377 | if self._threadtmp and not self._options.keep_tmpdir: |
|
377 | if self._threadtmp and not self._options.keep_tmpdir: | |
378 | shutil.rmtree(self._threadtmp, True) |
|
378 | shutil.rmtree(self._threadtmp, True) | |
379 |
|
379 | |||
|
380 | def setUp(self): | |||
|
381 | """Tasks to perform before run().""" | |||
|
382 | ||||
380 | def run(self): |
|
383 | def run(self): | |
381 | """Run this test instance. |
|
384 | """Run this test instance. | |
382 |
|
385 | |||
@@ -506,6 +509,9 b' class Test(object):' | |||||
506 |
|
509 | |||
507 | return res |
|
510 | return res | |
508 |
|
511 | |||
|
512 | def tearDown(self): | |||
|
513 | """Tasks to perform after run().""" | |||
|
514 | ||||
509 | def _run(self, testtmp, replacements, env): |
|
515 | def _run(self, testtmp, replacements, env): | |
510 | # This should be implemented in child classes to run tests. |
|
516 | # This should be implemented in child classes to run tests. | |
511 | return self._skip('unknown test type') |
|
517 | return self._skip('unknown test type') | |
@@ -1352,6 +1358,15 b' class TestRunner(object):' | |||||
1352 | # with it. |
|
1358 | # with it. | |
1353 | def run(self, result): |
|
1359 | def run(self, result): | |
1354 | try: |
|
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 | self.runTest() |
|
1370 | self.runTest() | |
1356 | except KeyboardInterrupt: |
|
1371 | except KeyboardInterrupt: | |
1357 | raise |
|
1372 | raise | |
@@ -1366,6 +1381,17 b' class TestRunner(object):' | |||||
1366 | except Exception: |
|
1381 | except Exception: | |
1367 | result.addError(self, sys.exc_info()) |
|
1382 | result.addError(self, sys.exc_info()) | |
1368 | else: |
|
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 | result.addSuccess(self) |
|
1395 | result.addSuccess(self) | |
1370 |
|
1396 | |||
1371 | def runTest(self): |
|
1397 | def runTest(self): |
General Comments 0
You need to be logged in to leave comments.
Login now