MCPcopy Index your code
hub / github.com/RustPython/RustPython / _from_module

Method _from_module

Lib/doctest.py:977–1004  ·  view source on GitHub ↗

Return true if the given object is defined in the given module.

(self, module, object)

Source from the content-addressed store, hash-verified

975 return tests
976
977 def _from_module(self, module, object):
978 """
979 Return true if the given object is defined in the given
980 module.
981 """
982 if module is None:
983 return True
984 elif inspect.getmodule(object) is not None:
985 return module is inspect.getmodule(object)
986 elif inspect.isfunction(object):
987 return module.__dict__ is object.__globals__
988 elif (inspect.ismethoddescriptor(object) or
989 inspect.ismethodwrapper(object)):
990 if hasattr(object, '__objclass__'):
991 obj_mod = object.__objclass__.__module__
992 elif hasattr(object, '__module__'):
993 obj_mod = object.__module__
994 else:
995 return True # [XX] no easy way to tell otherwise
996 return module.__name__ == obj_mod
997 elif inspect.isclass(object):
998 return module.__name__ == object.__module__
999 elif hasattr(object, '__module__'):
1000 return module.__name__ == object.__module__
1001 elif isinstance(object, property):
1002 return True # [XX] no way not be sure.
1003 else:
1004 raise ValueError("object must be a class or function")
1005
1006 def _is_routine(self, obj):
1007 """

Callers 1

_findMethod · 0.95

Calls 2

hasattrFunction · 0.85
isinstanceFunction · 0.85

Tested by

no test coverage detected