當前位置: 首頁>>代碼示例>>Python>>正文


Python options.mockable方法代碼示例

本文整理匯總了Python中tornado.options.options.mockable方法的典型用法代碼示例。如果您正苦於以下問題:Python options.mockable方法的具體用法?Python options.mockable怎麽用?Python options.mockable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tornado.options.options的用法示例。


在下文中一共展示了options.mockable方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: mockable

# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import mockable [as 別名]
def mockable(self):
        """Returns a wrapper around self that is compatible with
        `mock.patch <unittest.mock.patch>`.

        The `mock.patch <unittest.mock.patch>` function (included in
        the standard library `unittest.mock` package since Python 3.3,
        or in the third-party ``mock`` package for older versions of
        Python) is incompatible with objects like ``options`` that
        override ``__getattr__`` and ``__setattr__``.  This function
        returns an object that can be used with `mock.patch.object
        <unittest.mock.patch.object>` to modify option values::

            with mock.patch.object(options.mockable(), 'name', value):
                assert options.name == value
        """
        return _Mockable(self) 
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:18,代碼來源:options.py

示例2: mockable

# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import mockable [as 別名]
def mockable(self) -> "_Mockable":
        """Returns a wrapper around self that is compatible with
        `mock.patch <unittest.mock.patch>`.

        The `mock.patch <unittest.mock.patch>` function (included in
        the standard library `unittest.mock` package since Python 3.3,
        or in the third-party ``mock`` package for older versions of
        Python) is incompatible with objects like ``options`` that
        override ``__getattr__`` and ``__setattr__``.  This function
        returns an object that can be used with `mock.patch.object
        <unittest.mock.patch.object>` to modify option values::

            with mock.patch.object(options.mockable(), 'name', value):
                assert options.name == value
        """
        return _Mockable(self) 
開發者ID:opendevops-cn,項目名稱:opendevops,代碼行數:18,代碼來源:options.py

示例3: __setattr__

# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import mockable [as 別名]
def __setattr__(self, name, value):
        assert name not in self._originals, "don't reuse mockable objects"
        self._originals[name] = getattr(self._options, name)
        setattr(self._options, name, value) 
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:6,代碼來源:options.py

示例4: __setattr__

# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import mockable [as 別名]
def __setattr__(self, name: str, value: Any) -> None:
        assert name not in self._originals, "don't reuse mockable objects"
        self._originals[name] = getattr(self._options, name)
        setattr(self._options, name, value) 
開發者ID:opendevops-cn,項目名稱:opendevops,代碼行數:6,代碼來源:options.py

示例5: mock_option

# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import mockable [as 別名]
def mock_option(self, name, value):
        return mock.patch.object(options.mockable(), name, value) 
開發者ID:johan-sports,項目名稱:wscelery,代碼行數:4,代碼來源:test_command.py


注:本文中的tornado.options.options.mockable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。