Bug 1104271 - Provide a logger for Marionette test cases. r=mdas
authorDave Hunt <dhunt@mozilla.com>
Tue, 09 Dec 2014 07:28:00 -0500
changeset 219022 cb1647232cf499d94e6d54acd48c6fccd6cf5ffa
parent 219021 6179da6e8fbe42019613d3b565aea0087cf4a6bd
child 219023 417d7f6f3ffba596ef4f752a7cbf1014fc5b69e0
push id27952
push userryanvm@gmail.com
push dateWed, 10 Dec 2014 20:34:44 +0000
treeherdermozilla-central@a6282dfb2764 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmdas
bugs1104271
milestone37.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1104271 - Provide a logger for Marionette test cases. r=mdas
testing/marionette/client/marionette/marionette_test.py
--- a/testing/marionette/client/marionette/marionette_test.py
+++ b/testing/marionette/client/marionette/marionette_test.py
@@ -187,16 +187,17 @@ class CommonTestCase(unittest.TestCase):
     failureException = AssertionError
 
     def __init__(self, methodName, **kwargs):
         unittest.TestCase.__init__(self, methodName)
         self.loglines = []
         self.duration = 0
         self.start_time = 0
         self.expected = kwargs.pop('expected', 'pass')
+        self.logger = get_default_logger()
 
     def _addSkip(self, result, reason):
         addSkip = getattr(result, 'addSkip', None)
         if addSkip is not None:
             addSkip(self, reason)
         else:
             warnings.warn("TestResult has no addSkip method, skips not reported",
                           RuntimeWarning, 2)
@@ -604,32 +605,31 @@ class MarionetteJSTestCase(CommonTestCas
 
             self.assertTrue(not 'timeout' in self.jsFile,
                             'expected timeout not triggered')
 
             if 'fail' in self.jsFile:
                 self.assertTrue(len(results['failures']) > 0,
                                 "expected test failures didn't occur")
             else:
-                logger = get_default_logger()
                 for failure in results['failures']:
                     diag = "" if failure.get('diag') is None else failure['diag']
                     name = "got false, expected true" if failure.get('name') is None else failure['name']
-                    logger.test_status(self.test_name, name, 'FAIL',
-                                       message=diag)
+                    self.logger.test_status(self.test_name, name, 'FAIL',
+                                            message=diag)
                 for failure in results['expectedFailures']:
                     diag = "" if failure.get('diag') is None else failure['diag']
                     name = "got false, expected false" if failure.get('name') is None else failure['name']
-                    logger.test_status(self.test_name, name, 'FAIL',
-                                       expected='FAIL', message=diag)
+                    self.logger.test_status(self.test_name, name, 'FAIL',
+                                            expected='FAIL', message=diag)
                 for failure in results['unexpectedSuccesses']:
                     diag = "" if failure.get('diag') is None else failure['diag']
                     name = "got true, expected false" if failure.get('name') is None else failure['name']
-                    logger.test_status(self.test_name, name, 'PASS',
-                                       expected='FAIL', message=diag)
+                    self.logger.test_status(self.test_name, name, 'PASS',
+                                            expected='FAIL', message=diag)
                 self.assertEqual(0, len(results['failures']),
                                  '%d tests failed' % len(results['failures']))
                 if len(results['unexpectedSuccesses']) > 0:
                     raise _UnexpectedSuccess('')
                 if len(results['expectedFailures']) > 0:
                     raise _ExpectedFailure((AssertionError, AssertionError(''), None))
 
             self.assertTrue(results['passed']