
import traceback
import unittest

class PageTestResults(unittest.TestResult):
  def __init__(self):
    super(PageTestResults, self).__init__()
    self.successes = []

  def addError(self, test, err):
    if isinstance(test, unittest.TestCase):
      super(PageTestResults, self).addError(test, err)
    else:
      self.errors.append((test, ''.join(traceback.format_exception(*err))))

  def addFailure(self, test, err):
    if isinstance(test, unittest.TestCase):
      super(PageTestResults, self).addFailure(test, err)
    else:
      self.failures.append((test, ''.join(traceback.format_exception(*err))))

  def addSuccess(self, test):
    self.successes += test

  def AddError(self, page, err):
    self.addError(page.url, err)

  def AddFailure(self, page, err):
    self.addFailure(page.url, err)

  def AddSuccess(self, page):
    self.addSuccess(page.url)

  def AddSkip(self, page, reason):
    self.addSkip(page.url, reason)

  def AddFailureMessage(self, page, message):
    self.failures.append((page.url, message))

  def AddErrorMessage(self, page, message):
    self.errors.append((page.url, message))


import traceback
import unittest

class PageTestResults(unittest.TestResult):
  def __init__(self):
    super(PageTestResults, self).__init__()
    self.successes = []
    self.skipped = []

  def addError(self, test, err):
    if isinstance(test, unittest.TestCase):
      super(PageTestResults, self).addError(test, err)
    else:
      self.errors.append((test, ''.join(traceback.format_exception(*err))))

  def addFailure(self, test, err):
    if isinstance(test, unittest.TestCase):
      super(PageTestResults, self).addFailure(test, err)
    else:
      self.failures.append((test, ''.join(traceback.format_exception(*err))))

  def addSuccess(self, test):
    self.successes.append(test)

  def addSkip(self, test, reason):  # Python 2.7 has this in unittest.TestResult
    self.skipped.append((test, reason))

  def AddError(self, page, err):
    self.addError(page.url, err)

  def AddFailure(self, page, err):
    self.addFailure(page.url, err)

  def AddSuccess(self, page):
    self.addSuccess(page.url)

  def AddSkip(self, page, reason):
    self.addSkip(page.url, reason)

  def AddFailureMessage(self, page, message):
    self.failures.append((page.url, message))

  def AddErrorMessage(self, page, message):
    self.errors.append((page.url, message))

Add skipped and addSkip() to PageTestResults, for Python < 2.7.
[telemetry] Add skipped and addSkip() to PageTestResults, for Python < 2.7.

Fixing bots after https://chromiumcodereview.appspot.com/15153003/
Also fix typo in addSuccess(). successes is only used by record_wpr, so that mistake had no effect on the bots.

TBR=tonyg@chromium.org
BUG=None.
TEST=None.

Review URL: https://codereview.chromium.org/15237002

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@200641 0039d316-1c4b-4281-b951-d872f2087c98

  
  import traceback
  import unittest
  
  class PageTestResults(unittest.TestResult):
    def __init__(self):
      super(PageTestResults, self).__init__()
      self.successes = []
+     self.skipped = []
  
    def addError(self, test, err):
      if isinstance(test, unittest.TestCase):
        super(PageTestResults, self).addError(test, err)
      else:
        self.errors.append((test, ''.join(traceback.format_exception(*err))))
  
    def addFailure(self, test, err):
      if isinstance(test, unittest.TestCase):
        super(PageTestResults, self).addFailure(test, err)
      else:
        self.failures.append((test, ''.join(traceback.format_exception(*err))))
  
    def addSuccess(self, test):
-     self.successes += test
+     self.successes.append(test)
+ 
+   def addSkip(self, test, reason):  # Python 2.7 has this in unittest.TestResult
+     self.skipped.append((test, reason))
  
    def AddError(self, page, err):
      self.addError(page.url, err)
  
    def AddFailure(self, page, err):
      self.addFailure(page.url, err)
  
    def AddSuccess(self, page):
      self.addSuccess(page.url)
  
    def AddSkip(self, page, reason):
      self.addSkip(page.url, reason)
  
    def AddFailureMessage(self, page, message):
      self.failures.append((page.url, message))
  
    def AddErrorMessage(self, page, message):
      self.errors.append((page.url, message))
  
Add skipped and addSkip() to PageTestResults, for Python < 2.7.
## Code Before:

import traceback
import unittest

class PageTestResults(unittest.TestResult):
  def __init__(self):
    super(PageTestResults, self).__init__()
    self.successes = []

  def addError(self, test, err):
    if isinstance(test, unittest.TestCase):
      super(PageTestResults, self).addError(test, err)
    else:
      self.errors.append((test, ''.join(traceback.format_exception(*err))))

  def addFailure(self, test, err):
    if isinstance(test, unittest.TestCase):
      super(PageTestResults, self).addFailure(test, err)
    else:
      self.failures.append((test, ''.join(traceback.format_exception(*err))))

  def addSuccess(self, test):
    self.successes += test

  def AddError(self, page, err):
    self.addError(page.url, err)

  def AddFailure(self, page, err):
    self.addFailure(page.url, err)

  def AddSuccess(self, page):
    self.addSuccess(page.url)

  def AddSkip(self, page, reason):
    self.addSkip(page.url, reason)

  def AddFailureMessage(self, page, message):
    self.failures.append((page.url, message))

  def AddErrorMessage(self, page, message):
    self.errors.append((page.url, message))

## Instruction:
Add skipped and addSkip() to PageTestResults, for Python < 2.7.
## Code After:

import traceback
import unittest

class PageTestResults(unittest.TestResult):
  def __init__(self):
    super(PageTestResults, self).__init__()
    self.successes = []
    self.skipped = []

  def addError(self, test, err):
    if isinstance(test, unittest.TestCase):
      super(PageTestResults, self).addError(test, err)
    else:
      self.errors.append((test, ''.join(traceback.format_exception(*err))))

  def addFailure(self, test, err):
    if isinstance(test, unittest.TestCase):
      super(PageTestResults, self).addFailure(test, err)
    else:
      self.failures.append((test, ''.join(traceback.format_exception(*err))))

  def addSuccess(self, test):
    self.successes.append(test)

  def addSkip(self, test, reason):  # Python 2.7 has this in unittest.TestResult
    self.skipped.append((test, reason))

  def AddError(self, page, err):
    self.addError(page.url, err)

  def AddFailure(self, page, err):
    self.addFailure(page.url, err)

  def AddSuccess(self, page):
    self.addSuccess(page.url)

  def AddSkip(self, page, reason):
    self.addSkip(page.url, reason)

  def AddFailureMessage(self, page, message):
    self.failures.append((page.url, message))

  def AddErrorMessage(self, page, message):
    self.errors.append((page.url, message))
