def test_only_args(self): args_and_kwargs = ("argval1", "argval2", "argval3") args, kwargs = _process_args_and_kwargs(args_and_kwargs) assert args == ["argval1", "argval2", "argval3"] assert kwargs == {} args_and_kwargs = ("single_arg",) args, kwargs = _process_args_and_kwargs(args_and_kwargs) assert args == ["single_arg"] assert kwargs == {}
def test_mixed_args_and_kwargs(self): args_and_kwargs = ( "argval1", "--kwarg1", "kwval1", "argval2", "--kwarg2", "kwval2", ) with pytest.raises(ValueError): _process_args_and_kwargs(args_and_kwargs)
def test_empty_kwarg(self): args_and_kwargs = ( "argval1", "--kwarg1", "--kwarg2", "kwval2", ) with pytest.raises(ValueError): _process_args_and_kwargs(args_and_kwargs) args_and_kwargs = ("--empty_kwarg_only",) with pytest.raises(ValueError): _process_args_and_kwargs(args_and_kwargs)
def test_empty_equals_kwarg(self): args_and_kwargs = ( "argval1", "--kwarg1=--hello", "--kwarg2=", ) args, kwargs = _process_args_and_kwargs(args_and_kwargs) assert args == ["argval1"] assert kwargs == { "kwarg1": "--hello", "kwarg2": "", } args_and_kwargs = ("--empty_kwarg_only=",) args, kwargs = _process_args_and_kwargs(args_and_kwargs) assert args == [] assert kwargs == {"empty_kwarg_only": ""}
def test_only_kwargs(self): args_and_kwargs = ( "--kwarg1", "kwval1", "--kwarg2", "kwval2", "--kwarg3", "kwval3", ) args, kwargs = _process_args_and_kwargs(args_and_kwargs) assert args == [] assert kwargs == {"kwarg1": "kwval1", "kwarg2": "kwval2", "kwarg3": "kwval3"} args_and_kwargs = ( "--single_kwarg", "single_kwval", ) args, kwargs = _process_args_and_kwargs(args_and_kwargs) assert args == [] assert kwargs == {"single_kwarg": "single_kwval"}
def test_valid_args_and_kwargs(self): args_and_kwargs = ( "argval1", "argval2", "--kwarg1", "kwval1", "--kwarg2", "kwval2", ) args, kwargs = _process_args_and_kwargs(args_and_kwargs) assert args == ["argval1", "argval2"] assert kwargs == {"kwarg1": "kwval1", "kwarg2": "kwval2"}
def test_mixed_kwargs(self): args_and_kwargs = ( "argval1", "argval2", "--kwarg1==kw==val1", "--kwarg2", "kwval2", "--kwarg3", "=kwval=3", "--kwarg4=", "--kwarg5", "kwval5", ) args, kwargs = _process_args_and_kwargs(args_and_kwargs) assert args == ["argval1", "argval2"] assert kwargs == { "kwarg1": "=kw==val1", "kwarg2": "kwval2", "kwarg3": "=kwval=3", "kwarg4": "", "kwarg5": "kwval5", }
def test_empty_args_and_kwargs(self): for empty_val in [None, ()]: args, kwargs = _process_args_and_kwargs(empty_val) assert args == [] assert kwargs == {}