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
This commit is contained in:
Anjana Vakil 2016-08-17 18:38:56 +02:00
Родитель 6cde2b431b
Коммит 55065554ea
1 изменённых файлов: 20 добавлений и 1 удалений

Просмотреть файл

@ -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,