本文整理汇总了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.