tests/run-tests.py
changeset 21444 2b7d364690d8
parent 21443 a6845a042d46
child 21445 092b16448994
equal deleted inserted replaced
21443:a6845a042d46 21444:2b7d364690d8
   602                 else:
   602                 else:
   603                     rename(self._errpath, '%s.out' % self._path)
   603                     rename(self._errpath, '%s.out' % self._path)
   604 
   604 
   605                 return '.', self.name, ''
   605                 return '.', self.name, ''
   606 
   606 
       
   607         if self._unittest:
       
   608             if warned:
       
   609                 raise WarnTest(msg)
       
   610 
   607         return warned and '~' or '!', self.name, msg
   611         return warned and '~' or '!', self.name, msg
   608 
   612 
   609     def skip(self, msg):
   613     def skip(self, msg):
   610         if self._unittest:
   614         if self._unittest:
   611             raise SkipTest(msg)
   615             raise SkipTest(msg)
   989     """Raised to indicate that a test is to be skipped."""
   993     """Raised to indicate that a test is to be skipped."""
   990 
   994 
   991 class IgnoreTest(Exception):
   995 class IgnoreTest(Exception):
   992     """Raised to indicate that a test is to be ignored."""
   996     """Raised to indicate that a test is to be ignored."""
   993 
   997 
       
   998 class WarnTest(Exception):
       
   999     """Raised to indicate that a test warned."""
       
  1000 
   994 class TestResult(unittest._TextTestResult):
  1001 class TestResult(unittest._TextTestResult):
   995     """Holds results when executing via unittest."""
  1002     """Holds results when executing via unittest."""
   996     # Don't worry too much about accessing the non-public _TextTestResult.
  1003     # Don't worry too much about accessing the non-public _TextTestResult.
   997     # It is relatively common in Python testing tools.
  1004     # It is relatively common in Python testing tools.
   998     def __init__(self, *args, **kwargs):
  1005     def __init__(self, *args, **kwargs):
  1348                     raise
  1355                     raise
  1349                 except SkipTest, e:
  1356                 except SkipTest, e:
  1350                     result.addSkip(self, str(e))
  1357                     result.addSkip(self, str(e))
  1351                 except IgnoreTest, e:
  1358                 except IgnoreTest, e:
  1352                     result.addIgnore(self, str(e))
  1359                     result.addIgnore(self, str(e))
       
  1360                 except WarnTest, e:
       
  1361                     result.addWarn(self, str(e))
  1353                 except self.failureException:
  1362                 except self.failureException:
  1354                     result.addFailure(self, sys.exc_info())
  1363                     result.addFailure(self, sys.exc_info())
  1355                 except Exception:
  1364                 except Exception:
  1356                     result.addError(self, sys.exc_info())
  1365                     result.addError(self, sys.exc_info())
  1357                 else:
  1366                 else:
  1360             def runTest(self):
  1369             def runTest(self):
  1361                 code, tname, msg = t.run()
  1370                 code, tname, msg = t.run()
  1362 
  1371 
  1363                 if code == '!':
  1372                 if code == '!':
  1364                     self._result.failures.append((self, msg))
  1373                     self._result.failures.append((self, msg))
  1365                 elif code == '~':
       
  1366                     self._result.addWarn(self, msg)
       
  1367                 # Codes handled in run().
  1374                 # Codes handled in run().
  1368                 elif code in ('.', 's', 'i'):
  1375                 elif code in ('.', 's', 'i', '~'):
  1369                     pass
  1376                     pass
  1370                 else:
  1377                 else:
  1371                     self.fail('Unknown test result code: %s' % code)
  1378                     self.fail('Unknown test result code: %s' % code)
  1372 
  1379 
  1373             # We need this proxy until tearDown() is implemented.
  1380             # We need this proxy until tearDown() is implemented.