Bug 1290375 - Marionette has to report the test name and not runner.py for crashes. r?ato draft
authorHenrik Skupin <mail@hskupin.info>
Fri, 05 Aug 2016 15:06:15 +0200
changeset 397169 e2affaf077c2da255d550a48fad4b6b026199c57
parent 397156 5b5e427ce54d6ca4e6c120b9b5aceb5be41e2abe
child 527398 59b0a2c03466d62e1f0d55df3277f0f75480c886
push id25233
push userbmo:hskupin@gmail.com
push dateFri, 05 Aug 2016 13:06:50 +0000
reviewersato
bugs1290375
milestone51.0a1
Bug 1290375 - Marionette has to report the test name and not runner.py for crashes. r?ato MozReview-Commit-ID: 5WZv4bppp28
testing/marionette/client/marionette_driver/marionette.py
testing/marionette/harness/marionette/tests/unit/test_marionette.py
--- a/testing/marionette/client/marionette_driver/marionette.py
+++ b/testing/marionette/client/marionette_driver/marionette.py
@@ -1134,18 +1134,18 @@ class Marionette(object):
         return self.session
 
     @property
     def test_name(self):
         return self._test_name
 
     @test_name.setter
     def test_name(self, test_name):
-        if self._send_message("setTestName", {"value": test_name}):
-            self._test_name = test_name
+        self._send_message("setTestName", {"value": test_name})
+        self._test_name = test_name
 
     def delete_session(self):
         """Close the current session and disconnect from the server."""
         self._send_message("deleteSession")
         self.session_id = None
         self.session = None
         self.window = None
         self.client.close()
--- a/testing/marionette/harness/marionette/tests/unit/test_marionette.py
+++ b/testing/marionette/harness/marionette/tests/unit/test_marionette.py
@@ -1,27 +1,40 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import itertools
 
 from marionette_driver import errors
-from marionette.marionette_test import MarionetteTestCase as TC
+from marionette.marionette_test import MarionetteTestCase
 
 
-class TestProtocol1Errors(TC):
+class TestMarionetteProperties(MarionetteTestCase):
+
+    def test_correct_test_name(self):
+        """Test that the correct test name gets set."""
+        expected_test_name = '{module}.py {cls}.{func}'.format(
+            module=__name__,
+            cls=self.__class__.__name__,
+            func=self.test_correct_test_name.__name__,
+        )
+
+        self.assertEqual(self.marionette.test_name, expected_test_name)
+
+
+class TestProtocol1Errors(MarionetteTestCase):
     def setUp(self):
-        TC.setUp(self)
+        MarionetteTestCase.setUp(self)
         self.op = self.marionette.protocol
         self.marionette.protocol = 1
 
     def tearDown(self):
         self.marionette.protocol = self.op
-        TC.tearDown(self)
+        MarionetteTestCase.tearDown(self)
 
     def test_malformed_packet(self):
         for t in [{}, {"error": None}]:
             with self.assertRaisesRegexp(errors.MarionetteException, "Malformed packet"):
                 self.marionette._handle_error(t)
 
     def test_known_error_code(self):
         with self.assertRaises(errors.NoSuchElementException):
@@ -37,25 +50,25 @@ class TestProtocol1Errors(TC):
         with self.assertRaises(errors.MarionetteException):
             self.marionette._handle_error({"error": {"status": 123456}})
 
     def test_unknown_error_status(self):
         with self.assertRaises(errors.MarionetteException):
             self.marionette._handle_error({"error": {"status": "barbera"}})
 
 
-class TestProtocol2Errors(TC):
+class TestProtocol2Errors(MarionetteTestCase):
     def setUp(self):
-        TC.setUp(self)
+        MarionetteTestCase.setUp(self)
         self.op = self.marionette.protocol
         self.marionette.protocol = 2
 
     def tearDown(self):
         self.marionette.protocol = self.op
-        TC.tearDown(self)
+        MarionetteTestCase.tearDown(self)
 
     def test_malformed_packet(self):
         req = ["error", "message", "stacktrace"]
         ps = []
         for p in [p for i in range(0, len(req) + 1) for p in itertools.permutations(req, i)]:
             ps.append(dict((x, None) for x in p))
 
         for p in filter(lambda p: len(p) < 3, ps):