Bug 1291796 - Minor fixes to harness unit tests; r=maja_zf
authorAnjana Vakil <anjanavakil@gmail.com>
Fri, 26 Aug 2016 15:52:29 +0200
changeset 407049 0d7beb4dc862e03cc2d5410cd789eef0b22698c4
parent 407048 6a81df9a2129e940f62961e80203554c41c3109a
child 407050 5f43357fe5b4d280787e5e4d95c3be2422eef014
push id27893
push userbmo:gasolin@mozilla.com
push dateTue, 30 Aug 2016 03:41:38 +0000
reviewersmaja_zf
bugs1291796
milestone51.0a1
Bug 1291796 - Minor fixes to harness unit tests; r=maja_zf In test_marionette_runner.py, fix pytest warning raised when importing TestManifest class directly in global namespace. In test_marionette_arguments.py, improve readability by shortening/changing some names and removing unnecessary comments (not needed as code is self-explanatory). MozReview-Commit-ID: GDzxlEqb7MB
testing/marionette/harness/marionette/tests/harness_unit/test_marionette_arguments.py
testing/marionette/harness/marionette/tests/harness_unit/test_marionette_runner.py
--- a/testing/marionette/harness/marionette/tests/harness_unit/test_marionette_arguments.py
+++ b/testing/marionette/harness/marionette/tests/harness_unit/test_marionette_arguments.py
@@ -1,34 +1,32 @@
 # 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 pytest
 
 from marionette.runtests import MarionetteArguments
 
 
-@pytest.mark.parametrize("sock_timeout_value", ['A', '10', '1B-', '1C2', '44.35'])
-def test_parse_arg_socket_timeout_with_multiple_values(sock_timeout_value):
-    argv = ['marionette', '--socket-timeout', sock_timeout_value]
+@pytest.mark.parametrize("socket_timeout", ['A', '10', '1B-', '1C2', '44.35'])
+def test_parse_arg_socket_timeout(socket_timeout):
+    argv = ['marionette', '--socket-timeout', socket_timeout]
     parser = MarionetteArguments()
 
     def _is_float_convertible(value):
         try:
             float(value)
             return True
         except:
             return False
 
-    if not _is_float_convertible(sock_timeout_value):
-        # should raising exception, since sock_timeout must be convertible to float.
+    if not _is_float_convertible(socket_timeout):
         with pytest.raises(SystemExit) as ex:
             parser.parse_args(args=argv)
         assert ex.value.code == 2
     else:
-        # should pass without raising exception.
         args = parser.parse_args(args=argv)
-        assert hasattr(args, 'socket_timeout') and args.socket_timeout == float(sock_timeout_value)
+        assert hasattr(args, 'socket_timeout') and args.socket_timeout == float(socket_timeout)
 
 
 if __name__ == '__main__':
     import sys
     sys.exit(pytest.main(['--verbose', __file__]))
--- a/testing/marionette/harness/marionette/tests/harness_unit/test_marionette_runner.py
+++ b/testing/marionette/harness/marionette/tests/harness_unit/test_marionette_runner.py
@@ -1,17 +1,17 @@
 # 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 pytest
 
 from mock import Mock, patch, mock_open, sentinel, DEFAULT
 
 from marionette.runtests import MarionetteTestRunner
-from manifestparser import TestManifest
+import manifestparser
 
 
 @pytest.fixture
 def runner(mach_parsed_kwargs):
     """
     MarionetteTestRunner instance initialized with default options.
     """
     return MarionetteTestRunner(**mach_parsed_kwargs)
@@ -90,17 +90,18 @@ def manifest_fixture(request):
     keys = ('path', 'expected', 'disabled')
     active_tests = [dict(zip(keys, values)) for values in included]
 
     class ManifestFixture:
         def __init__(self, name, tests):
             self.filepath = "/path/to/fake/manifest.ini"
             self.n_disabled = len([t for t in tests if 'disabled' in t])
             self.n_enabled = len(tests) - self.n_disabled
-            mock_manifest = Mock(spec=TestManifest, active_tests=Mock(return_value=tests))
+            mock_manifest = Mock(spec=manifestparser.TestManifest,
+                                 active_tests=Mock(return_value=tests))
             self.mock_manifest = Mock(return_value=mock_manifest)
             self.__repr__ = lambda: "<ManifestFixture {}>".format(name)
 
     return ManifestFixture(request.param, active_tests)
 
 
 def test_args_passed_to_driverclass(mock_runner):
     built_kwargs = {'arg1': 'value1', 'arg2': 'value2'}