def test_get_non_function(self): """Raise an error if lookup returns something that isn't a function""" with pytest.raises(InvalidTypeError): get_func_in_module(__name__, 'NOT_A_FUNCTION')
def test_get_settable_property(self): """We can't disambiguate between getters, setters, and deleters""" func = Dummy.a_settable_property.fget with pytest.raises(InvalidTypeError): get_func_in_module(func.__module__, func.__qualname__)
def test_get_property(self): """We should be able to look up properties that are only getters""" func = Dummy.a_property.fget obj = get_func_in_module(func.__module__, func.__qualname__) assert obj == func
def test_get_method(self): """Make sure we return the underlying function for boundmethods""" meth = Dummy.a_class_method obj = get_func_in_module(meth.__module__, meth.__qualname__) assert obj == meth.__func__
def to_trace(self) -> CallTrace: function = get_func_in_module(self.module, self.qualname) arg_types = arg_types_from_json(self.arg_types) return_type = maybe_decode_type(type_from_json, self.return_type) yield_type = maybe_decode_type(type_from_json, self.yield_type) return CallTrace(function, arg_types, return_type, yield_type)
def test_get_cached_property(self): """We should be able to look up properties that are decorated with django.utils.functional.cached_property""" func = Dummy.a_cached_property.func obj = get_func_in_module(func.__module__, func.__qualname__) assert obj == func