MCPcopy Index your code
hub / github.com/python/cpython / __dir__

Method __dir__

Lib/unittest/mock.py:788–803  ·  view source on GitHub ↗

Filter the output of `dir(mock)` to only useful members.

(self)

Source from the content-addressed store, hash-verified

786
787
788 def __dir__(self):
789 """Filter the output of `dir(mock)` to only useful members."""
790 if not FILTER_DIR:
791 return object.__dir__(self)
792
793 extras = self._mock_methods or []
794 from_type = dir(type(self))
795 from_dict = list(self.__dict__)
796 from_child_mocks = [
797 m_name for m_name, m_value in self._mock_children.items()
798 if m_value is not _deleted]
799
800 from_type = [e for e in from_type if not e.startswith('_')]
801 from_dict = [e for e in from_dict if not e.startswith('_') or
802 _is_magic(e)]
803 return sorted(set(extras + from_type + from_dict + from_child_mocks))
804
805
806 def __setattr__(self, name, value):

Callers

nothing calls this directly

Calls 5

listClass · 0.85
_is_magicFunction · 0.85
setFunction · 0.85
itemsMethod · 0.45
startswithMethod · 0.45

Tested by

no test coverage detected