Filter the output of `dir(mock)` to only useful members.
(self)
| 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): |
nothing calls this directly
no test coverage detected