本文整理匯總了Python中mock.FILTER_DIR屬性的典型用法代碼示例。如果您正苦於以下問題:Python mock.FILTER_DIR屬性的具體用法?Python mock.FILTER_DIR怎麽用?Python mock.FILTER_DIR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類mock
的用法示例。
在下文中一共展示了mock.FILTER_DIR屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __dir__
# 需要導入模塊: import mock [as 別名]
# 或者: from mock import FILTER_DIR [as 別名]
def __dir__(self):
"""Filter the output of `dir(mock)` to only useful members."""
if not mock.FILTER_DIR and getattr(object, '__dir__', None):
# object.__dir__ is not in 2.7
return object.__dir__(self)
extras = self._mock_methods or []
from_type = dir(type(self))
from_dict = list(self.__dict__)
if mock.FILTER_DIR:
# object.__dir__ is not in 2.7
from_type = [e for e in from_type if not e.startswith('_')]
from_dict = [e for e in from_dict if not e.startswith('_') or
_is_magic(e)]
return sorted(set(extras + from_type + from_dict +
list(self._mock_children)))
示例2: __dir__
# 需要導入模塊: import mock [as 別名]
# 或者: from mock import FILTER_DIR [as 別名]
def __dir__(self):
"""Filter the output of `dir(mock)` to only useful members."""
if not mock.FILTER_DIR and getattr(object, '__dir__', None):
# object.__dir__ is not in 2.7
return object.__dir__(self)
extras = self._mock_methods or []
from_type = dir(type(self))
from_dict = list(self.__dict__)
from_child_mocks = [
m_name for m_name, m_value in self._mock_children.items()
if m_value is not _deleted]
if mock.FILTER_DIR:
# object.__dir__ is not in 2.7
from_type = [e for e in from_type if not e.startswith('_')]
from_dict = [e for e in from_dict if not e.startswith('_') or
_is_magic(e)]
return sorted(set(extras + from_type + from_dict + from_child_mocks))
示例3: _isidentifier
# 需要導入模塊: import mock [as 別名]
# 或者: from mock import FILTER_DIR [as 別名]
def _isidentifier(string):
if string in keyword.kwlist:
return False
return regex.match(string)
# NOTE: This FILTER_DIR is not used. The binding in mock.FILTER_DIR is.