def test__get_func_and_arg__anonymous_funcs(): """Test `_get_func_and_arg` errors for anonymous functions.""" with pytest.raises(SyntaxError): (lambda: _func)()(a=_get_func_and_arg()) with pytest.raises(SyntaxError): functools.partial(lambda *a, **k: (a, k), a=_get_func_and_arg())
def test__get_func_and_arg__builtin(): """Test `_get_func_and_arg` errors if partial only has keyword args.""" with pytest.raises(SyntaxError): functools.partial(a=_get_func_and_arg())
def test__get_func_and_arg__partial_with_attributes(): """Test `_get_func_and_arg` can resolve partials with attributes.""" partial = functools.partial(_func.attr.bttr, a=_get_func_and_arg()) assert partial() == (tuple(), {"a": (_func.attr.bttr, "a")})
def test__get_func_and_arg__partial(): """Test `_get_func_and_arg` can resolve partials.""" partial = functools.partial(_func, a=_get_func_and_arg()) assert partial() == (tuple(), {"a": (_func, "a")})
def test__get_func_and_arg__attributes(): """Test `_get_func_and_arg` can parse attributes.""" result = _func.attr.bttr(a=_get_func_and_arg()) assert result == (tuple(), {"a": (_func.attr.bttr, "a")})
def test__get_func_and_arg__not_defined_func(): """Test `_get_func_and_arg` can handle when func isn't defined.""" with pytest.raises(SyntaxError): _get_func_and_arg("a")
def test__get_func_and_arg__defined_func_and_arg(): """Test `_get_func_and_arg` can handle if the function and argument is passed in.""" assert _get_func_and_arg("a", _func) == (_func, "a")
def test__get_func_and_arg__not_defined_arg(): """Test `_get_func_and_arg` can handle when arg isn't defined.""" result = _func(_get_func_and_arg()) assert result == (((_func, None), ), {})
def test__get_func_and_arg__defined_func(): """Test `_get_func_and_arg` can handle if the function is passed in.""" result = (lambda: _func)()(a=_get_func_and_arg(func=_func)) assert result == (tuple(), {"a": (_func, "a")})
def test__get_func_and_arg__class_special(): """Test `_get_func_and_arg` can handle a special class func.""" with pytest.raises(SyntaxError): Obj()(a=_get_func_and_arg())
def test__get_func_and_arg__defined_arg(): """Test `_get_func_and_arg` can handle if argument name is passed in.""" result = _func(_get_func_and_arg("a")) assert result == (((_func, "a"), ), {})
def test__get_func_and_arg__class_static_attribute(): """Test `_get_func_and_arg` can handle static attributes.""" result = OtherObj().static_obj.new(a=_get_func_and_arg()).results assert result == (tuple(), {"a": (OtherObj.static_obj.new.__func__, "a")})
def test__get_func_and_arg__class_attribute(): """Test `_get_func_and_arg` can handle instantiated attributes.""" with pytest.raises(SyntaxError): OtherObj().obj.new(a=_get_func_and_arg())
def test__get_func_and_arg__class_func(): """Test `_get_func_and_arg` can handle a class func.""" result = Obj().func(a=_get_func_and_arg()) assert result == (tuple(), {"a": (Obj.func, "a")})
def test__get_func_and_arg__class_init(): """Test `_get_func_and_arg` can handle a class instantiation.""" result = Obj(a=_get_func_and_arg()).results assert result == (tuple(), {"a": (Obj, "a")})
def test__get_func_and_arg(): """Test `_get_func_and_arg` can handle the basic case.""" result = _func(a=_get_func_and_arg()) assert result == (tuple(), {"a": (_func, "a")})