From 55065554ea8217a9ea14dd5c76523d5fc6ce4cc6 Mon Sep 17 00:00:00 2001 From: Anjana Vakil Date: Wed, 17 Aug 2016 18:38:56 +0200 Subject: [PATCH] Bug 1284847 - Test args passed to runner/driver classes; r=maja_zf Add tests to test_marionette_runner.py to verify that: - when the MarionetteHarness constructor is called, the arguments to that call are passed on to the _runner_class constructor - when run_tests() is called on the runner, the output of _build_kwargs is passed on as arguments to the call to the driverclass constructor In combination with a test of the runner's _build_kwargs method, this should ensure that the driver class constructor is being called with the appropriate arguments based on the input to the harness class constructor. MozReview-Commit-ID: 4U3sXxHSIpS --HG-- extra : rebase_source : 3ca439613f13c6064c0dcbfb603c049f75233b71 --- .../harness_unit/test_marionette_runner.py | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/testing/marionette/harness/marionette/tests/harness_unit/test_marionette_runner.py b/testing/marionette/harness/marionette/tests/harness_unit/test_marionette_runner.py index 855947f3dfa5..3764c49bfe27 100644 --- a/testing/marionette/harness/marionette/tests/harness_unit/test_marionette_runner.py +++ b/testing/marionette/harness/marionette/tests/harness_unit/test_marionette_runner.py @@ -2,7 +2,7 @@ # 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 patch, Mock, DEFAULT, mock_open, MagicMock +from mock import patch, Mock, DEFAULT, mock_open, MagicMock, sentinel from marionette.runtests import ( MarionetteTestRunner, @@ -243,6 +243,25 @@ def test_call_harness_with_no_args_yields_num_failures(runner_class): assert failed_or_crashed == 0 +def test_args_passed_to_runner_class(mach_parsed_kwargs, runner_class): + arg_list = mach_parsed_kwargs.keys() + arg_list.remove('tests') + mach_parsed_kwargs.update([(a, getattr(sentinel, a)) for a in arg_list]) + harness = MarionetteHarness(runner_class, args=mach_parsed_kwargs) + harness.process_args = Mock() + harness.run() + for arg in arg_list: + assert harness._runner_class.call_args[1][arg] is getattr(sentinel, arg) + + +def test_args_passed_to_driverclass(mock_runner): + built_kwargs = {'arg1': 'value1', 'arg2': 'value2'} + mock_runner._build_kwargs = Mock(return_value=built_kwargs) + with pytest.raises(IOError): + mock_runner.run_tests(['fake_tests.ini']) + assert mock_runner.driverclass.call_args[1] == built_kwargs + + def test_harness_sets_up_default_test_handlers(mach_parsed_kwargs): """ If the necessary TestCase is not in test_handlers,