Exemplo n.º 1
0
 def kwarg_builder(new_items, return_socket=False):
     mach_parsed_kwargs.update(new_items)
     runner = MarionetteTestRunner(**mach_parsed_kwargs)
     with patch('marionette_harness.runner.base.socket') as socket:
         built_kwargs = runner._build_kwargs()
     if return_socket:
         return built_kwargs, socket
     return built_kwargs
def test_parse_opt_args_emulator(mach_parsed_kwargs, arg_name, arg_dest, arg_value, expected_value):
    parser = MarionetteArguments()
    parsed_args = parser.parse_args(['--' + arg_name, arg_value])
    result = vars(parsed_args)
    assert result.get(arg_dest) == expected_value
    mach_parsed_kwargs[arg_dest] = result[arg_dest]
    mach_parsed_kwargs["emulator"] = True
    runner = MarionetteTestRunner(**mach_parsed_kwargs)
    built_kwargs = runner._build_kwargs()
    assert built_kwargs[arg_dest] == expected_value
Exemplo n.º 3
0
def test_load_testvars_throws_expected_errors(mach_parsed_kwargs):
    mach_parsed_kwargs['testvars'] = ['some_bad_path.json']
    runner = MarionetteTestRunner(**mach_parsed_kwargs)
    with pytest.raises(IOError) as io_exc:
        runner._load_testvars()
    assert 'does not exist' in io_exc.value.message
    with patch('os.path.exists', return_value=True):
        with patch('__builtin__.open', mock_open(read_data='[not {valid JSON]')):
            with pytest.raises(Exception) as json_exc:
                runner._load_testvars()
    assert 'not properly formatted' in json_exc.value.message