Bug 1336124 - Only delete session if one exists when testing capabilities; r=maja_zf
authorAndreas Tolfsen <ato@mozilla.com>
Fri, 03 Feb 2017 16:53:31 +0000
changeset 340950 c4441c1492fd729592539121f7400e565e53b75e
parent 340949 6d17a85df7e32778362ba54466d1a4a224f645b8
child 340951 ce216a8c272f759d04d15fbdd663889d05c0f901
push id31321
push userkwierso@gmail.com
push dateTue, 07 Feb 2017 01:37:59 +0000
treeherdermozilla-central@4f8b2d44eaa0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaja_zf
bugs1336124
milestone54.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 1336124 - Only delete session if one exists when testing capabilities; r=maja_zf MozReview-Commit-ID: IEqHzADUQow
testing/marionette/harness/marionette_harness/tests/unit/test_capabilities.py
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_capabilities.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_capabilities.py
@@ -103,40 +103,44 @@ class TestCapabilities(MarionetteTestCas
 class TestCapabilityMatching(MarionetteTestCase):
     allowed = [None, "*"]
     disallowed = ["", 42, True, {}, []]
 
     def setUp(self):
         MarionetteTestCase.setUp(self)
         self.browser_name = self.marionette.session_capabilities["browserName"]
         self.platform_name = self.marionette.session_capabilities["platformName"]
-        self.marionette.delete_session()
+        self.delete_session()
+
+    def delete_session(self):
+        if self.marionette.session is not None:
+            self.marionette.delete_session()
 
     def test_browser_name_desired(self):
         self.marionette.start_session({"desiredCapabilities": {"browserName": self.browser_name}})
         self.assertEqual(self.marionette.session_capabilities["browserName"], self.browser_name)
 
     def test_browser_name_required(self):
         self.marionette.start_session({"requiredCapabilities": {"browserName": self.browser_name}})
         self.assertEqual(self.marionette.session_capabilities["browserName"], self.browser_name)
 
     def test_browser_name_desired_allowed_types(self):
         for typ in self.allowed:
-            self.marionette.delete_session()
+            self.delete_session()
             self.marionette.start_session({"desiredCapabilities": {"browserName": typ}})
             self.assertEqual(self.marionette.session_capabilities["browserName"], self.browser_name)
 
     def test_browser_name_desired_disallowed_types(self):
         for typ in self.disallowed:
             with self.assertRaises(SessionNotCreatedException):
                 self.marionette.start_session({"desiredCapabilities": {"browserName": typ}})
 
     def test_browser_name_required_allowed_types(self):
         for typ in self.allowed:
-            self.marionette.delete_session()
+            self.delete_session()
             self.marionette.start_session({"requiredCapabilities": {"browserName": typ}})
             self.assertEqual(self.marionette.session_capabilities["browserName"], self.browser_name)
 
     def test_browser_name_requried_disallowed_types(self):
         for typ in self.disallowed:
             with self.assertRaises(SessionNotCreatedException):
                 self.marionette.start_session({"requiredCapabilities": {"browserName": typ}})
 
@@ -158,28 +162,28 @@ class TestCapabilityMatching(MarionetteT
         self.assertEqual(self.marionette.session_capabilities["platformName"], self.platform_name)
 
     def test_platform_name_required(self):
         self.marionette.start_session({"requiredCapabilities": {"platformName": self.platform_name}})
         self.assertEqual(self.marionette.session_capabilities["platformName"], self.platform_name)
 
     def test_platform_name_desired_allowed_types(self):
         for typ in self.allowed:
-            self.marionette.delete_session()
+            self.delete_session()
             self.marionette.start_session({"desiredCapabilities": {"platformName": typ}})
             self.assertEqual(self.marionette.session_capabilities["platformName"], self.platform_name)
 
     def test_platform_name_desired_disallowed_types(self):
         for typ in self.disallowed:
             with self.assertRaises(SessionNotCreatedException):
                 self.marionette.start_session({"desiredCapabilities": {"platformName": typ}})
 
     def test_platform_name_required_allowed_types(self):
         for typ in self.allowed:
-            self.marionette.delete_session()
+            self.delete_session()
             self.marionette.start_session({"requiredCapabilities": {"platformName": typ}})
             self.assertEqual(self.marionette.session_capabilities["platformName"], self.platform_name)
 
     def test_platform_name_requried_disallowed_types(self):
         for typ in self.disallowed:
             with self.assertRaises(SessionNotCreatedException):
                 self.marionette.start_session({"requiredCapabilities": {"platformName": typ}})
 
@@ -199,28 +203,28 @@ class TestCapabilityMatching(MarionetteT
     def test_accept_insecure_certs(self):
         for capability_type in ["desiredCapabilities", "requiredCapabilities"]:
             print("testing {}".format(capability_type))
             for value in ["", 42, {}, []]:
                 print("  type {}".format(type(value)))
                 with self.assertRaises(SessionNotCreatedException):
                     self.marionette.start_session({capability_type: {"acceptInsecureCerts": value}})
 
-        self.marionette.delete_session()
+        self.delete_session()
         self.marionette.start_session({"desiredCapabilities": {"acceptInsecureCerts": True}})
         self.assertTrue(self.marionette.session_capabilities["acceptInsecureCerts"])
-        self.marionette.delete_session()
+        self.delete_session()
         self.marionette.start_session({"requiredCapabilities": {"acceptInsecureCerts": True}})
 
         self.assertTrue(self.marionette.session_capabilities["acceptInsecureCerts"])
 
     def test_page_load_strategy(self):
         for strategy in ["none", "eager", "normal"]:
             print("valid strategy {}".format(strategy))
-            self.marionette.delete_session()
+            self.delete_session()
             self.marionette.start_session({"desiredCapabilities": {"pageLoadStrategy": strategy}})
             self.assertEqual(self.marionette.session_capabilities["pageLoadStrategy"], strategy)
 
         for value in ["", "EAGER", True, 42, {}, []]:
             print("invalid strategy {}".format(value))
             with self.assertRaises(SessionNotCreatedException):
                 self.marionette.start_session({"desiredCapabilities": {"pageLoadStrategy": value}})