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


Python interface.Interface方法代碼示例

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


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

示例1: test_class_has_required_method_derived

# 需要導入模塊: from zope import interface [as 別名]
# 或者: from zope.interface import Interface [as 別名]
def test_class_has_required_method_derived(self):
        from zope.interface import Interface
        from zope.interface import implementer

        class IBase(Interface):
            def method():
                pass

        class IDerived(IBase):
            pass

        @implementer(IDerived)
        class Current(object):

            def method(self):
                pass

        self._callFUT(IDerived, Current) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:20,代碼來源:test_verify.py

示例2: test_add_explorer_view

# 需要導入模塊: from zope import interface [as 別名]
# 或者: from zope.interface import Interface [as 別名]
def test_add_explorer_view() -> None:
    """Test registration of a view serving the Swagger UI."""
    with testConfig() as config:
        config.include("pyramid_openapi3")

        with tempfile.NamedTemporaryFile() as document:
            document.write(MINIMAL_DOCUMENT)
            document.seek(0)

            config.pyramid_openapi3_spec(
                document.name, route="/foo.yaml", route_name="foo_api_spec"
            )

        config.pyramid_openapi3_add_explorer()
        request = config.registry.queryUtility(
            IRouteRequest, name="pyramid_openapi3.explorer"
        )
        view = config.registry.adapters.registered(
            (IViewClassifier, request, Interface), IView, name=""
        )
        response = view(request=DummyRequest(config=config), context=None)
        assert b"<title>Swagger UI</title>" in response.body 
開發者ID:Pylons,項目名稱:pyramid_openapi3,代碼行數:24,代碼來源:test_views.py

示例3: test_explorer_view_missing_spec

# 需要導入模塊: from zope import interface [as 別名]
# 或者: from zope.interface import Interface [as 別名]
def test_explorer_view_missing_spec() -> None:
    """Test graceful failure if explorer view is not registered."""
    with testConfig() as config:
        config.include("pyramid_openapi3")
        config.pyramid_openapi3_add_explorer()

        request = config.registry.queryUtility(
            IRouteRequest, name="pyramid_openapi3.explorer"
        )
        view = config.registry.adapters.registered(
            (IViewClassifier, request, Interface), IView, name=""
        )
        with pytest.raises(
            ConfigurationError,
            match="You need to call config.pyramid_openapi3_spec for explorer to work.",
        ):
            view(request=DummyRequest(config=config), context=None) 
開發者ID:Pylons,項目名稱:pyramid_openapi3,代碼行數:19,代碼來源:test_views.py

示例4: test_asStructuredText_empty_with_multiline_docstring

# 需要導入模塊: from zope import interface [as 別名]
# 或者: from zope.interface import Interface [as 別名]
def test_asStructuredText_empty_with_multiline_docstring(self):
        from zope.interface import Interface
        EXPECTED = '\n'.join([
            "IEmpty",
            "",
            " This is an empty interface.",
            " ",
            ("             It can be used to annotate any class or object, "
                             "because it promises"),
            "             nothing.",
            "",
            " Attributes:",
            "",
            " Methods:",
            "",
            ""
        ])
        class IEmpty(Interface):
            """ This is an empty interface.

            It can be used to annotate any class or object, because it promises
            nothing.
            """
        self.assertEqual(self._callFUT(IEmpty), EXPECTED) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:26,代碼來源:test_document.py

示例5: test_asStructuredText_with_attribute_no_docstring

# 需要導入模塊: from zope import interface [as 別名]
# 或者: from zope.interface import Interface [as 別名]
def test_asStructuredText_with_attribute_no_docstring(self):
        from zope.interface import Attribute
        from zope.interface import Interface
        EXPECTED = '\n\n'.join([
            "IHasAttribute",
            " This interface has an attribute.",
            " Attributes:",
            "  an_attribute -- no documentation",
            " Methods:",
            ""
        ])
        class IHasAttribute(Interface):
            """ This interface has an attribute.
            """
            an_attribute = Attribute('an_attribute')

        self.assertEqual(self._callFUT(IHasAttribute), EXPECTED) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:19,代碼來源:test_document.py

示例6: test_asStructuredText_with_attribute_with_docstring

# 需要導入模塊: from zope import interface [as 別名]
# 或者: from zope.interface import Interface [as 別名]
def test_asStructuredText_with_attribute_with_docstring(self):
        from zope.interface import Attribute
        from zope.interface import Interface
        EXPECTED = '\n\n'.join([
            "IHasAttribute",
            " This interface has an attribute.",
            " Attributes:",
            "  an_attribute -- This attribute is documented.",
            " Methods:",
            ""
        ])
        class IHasAttribute(Interface):
            """ This interface has an attribute.
            """
            an_attribute = Attribute('an_attribute',
                                     'This attribute is documented.')

        self.assertEqual(self._callFUT(IHasAttribute), EXPECTED) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:20,代碼來源:test_document.py

示例7: test_asStructuredText_with_method_positional_args_no_docstring

# 需要導入模塊: from zope import interface [as 別名]
# 或者: from zope.interface import Interface [as 別名]
def test_asStructuredText_with_method_positional_args_no_docstring(self):
        from zope.interface import Interface
        EXPECTED = '\n\n'.join([
            "IHasMethod",
            " This interface has a method.",
            " Attributes:",
            " Methods:",
            "  aMethod(first, second) -- no documentation",
            ""
        ])
        class IHasMethod(Interface):
            """ This interface has a method.
            """
            def aMethod(first, second):
                pass

        self.assertEqual(self._callFUT(IHasMethod), EXPECTED) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:19,代碼來源:test_document.py

示例8: test_asStructuredText_with_method_starargs_no_docstring

# 需要導入模塊: from zope import interface [as 別名]
# 或者: from zope.interface import Interface [as 別名]
def test_asStructuredText_with_method_starargs_no_docstring(self):
        from zope.interface import Interface
        EXPECTED = '\n\n'.join([
            "IHasMethod",
            " This interface has a method.",
            " Attributes:",
            " Methods:",
            "  aMethod(first, second, *rest) -- no documentation",
            ""
        ])
        class IHasMethod(Interface):
            """ This interface has a method.
            """
            def aMethod(first, second, *rest):
                pass

        self.assertEqual(self._callFUT(IHasMethod), EXPECTED) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:19,代碼來源:test_document.py

示例9: test_asStructuredText_with_method_kwargs_no_docstring

# 需要導入模塊: from zope import interface [as 別名]
# 或者: from zope.interface import Interface [as 別名]
def test_asStructuredText_with_method_kwargs_no_docstring(self):
        from zope.interface import Interface
        EXPECTED = '\n\n'.join([
            "IHasMethod",
            " This interface has a method.",
            " Attributes:",
            " Methods:",
            "  aMethod(first, second, **kw) -- no documentation",
            ""
        ])
        class IHasMethod(Interface):
            """ This interface has a method.
            """
            def aMethod(first, second, **kw):
                pass

        self.assertEqual(self._callFUT(IHasMethod), EXPECTED) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:19,代碼來源:test_document.py

示例10: test_asStructuredText_with_method_with_docstring

# 需要導入模塊: from zope import interface [as 別名]
# 或者: from zope.interface import Interface [as 別名]
def test_asStructuredText_with_method_with_docstring(self):
        from zope.interface import Interface
        EXPECTED = '\n\n'.join([
            "IHasMethod",
            " This interface has a method.",
            " Attributes:",
            " Methods:",
            "  aMethod() -- This method is documented.",
            ""
        ])
        class IHasMethod(Interface):
            """ This interface has a method.
            """
            def aMethod():
                """This method is documented.
                """

        self.assertEqual(self._callFUT(IHasMethod), EXPECTED) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:20,代碼來源:test_document.py

示例11: test_asReStructuredText_empty_with_multiline_docstring

# 需要導入模塊: from zope import interface [as 別名]
# 或者: from zope.interface import Interface [as 別名]
def test_asReStructuredText_empty_with_multiline_docstring(self):
        from zope.interface import Interface
        EXPECTED = '\n'.join([
            "``IEmpty``",
            "",
            " This is an empty interface.",
            " ",
            ("             It can be used to annotate any class or object, "
                             "because it promises"),
            "             nothing.",
            "",
            " Attributes:",
            "",
            " Methods:",
            "",
            ""
        ])
        class IEmpty(Interface):
            """ This is an empty interface.

            It can be used to annotate any class or object, because it promises
            nothing.
            """
        self.assertEqual(self._callFUT(IEmpty), EXPECTED) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:26,代碼來源:test_document.py

示例12: test_asReStructuredText_with_attribute_no_docstring

# 需要導入模塊: from zope import interface [as 別名]
# 或者: from zope.interface import Interface [as 別名]
def test_asReStructuredText_with_attribute_no_docstring(self):
        from zope.interface import Attribute
        from zope.interface import Interface
        EXPECTED = '\n\n'.join([
            "``IHasAttribute``",
            " This interface has an attribute.",
            " Attributes:",
            "  ``an_attribute`` -- no documentation",
            " Methods:",
            ""
        ])
        class IHasAttribute(Interface):
            """ This interface has an attribute.
            """
            an_attribute = Attribute('an_attribute')

        self.assertEqual(self._callFUT(IHasAttribute), EXPECTED) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:19,代碼來源:test_document.py

示例13: test_asReStructuredText_with_attribute_with_docstring

# 需要導入模塊: from zope import interface [as 別名]
# 或者: from zope.interface import Interface [as 別名]
def test_asReStructuredText_with_attribute_with_docstring(self):
        from zope.interface import Attribute
        from zope.interface import Interface
        EXPECTED = '\n\n'.join([
            "``IHasAttribute``",
            " This interface has an attribute.",
            " Attributes:",
            "  ``an_attribute`` -- This attribute is documented.",
            " Methods:",
            ""
        ])
        class IHasAttribute(Interface):
            """ This interface has an attribute.
            """
            an_attribute = Attribute('an_attribute',
                                     'This attribute is documented.')

        self.assertEqual(self._callFUT(IHasAttribute), EXPECTED) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:20,代碼來源:test_document.py

示例14: test_asReStructuredText_with_method_no_args_no_docstring

# 需要導入模塊: from zope import interface [as 別名]
# 或者: from zope.interface import Interface [as 別名]
def test_asReStructuredText_with_method_no_args_no_docstring(self):
        from zope.interface import Interface
        EXPECTED = '\n\n'.join([
            "``IHasMethod``",
            " This interface has a method.",
            " Attributes:",
            " Methods:",
            "  ``aMethod()`` -- no documentation",
            ""
        ])
        class IHasMethod(Interface):
            """ This interface has a method.
            """
            def aMethod():
                pass

        self.assertEqual(self._callFUT(IHasMethod), EXPECTED) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:19,代碼來源:test_document.py

示例15: test_asReStructuredText_with_method_starargs_no_docstring

# 需要導入模塊: from zope import interface [as 別名]
# 或者: from zope.interface import Interface [as 別名]
def test_asReStructuredText_with_method_starargs_no_docstring(self):
        from zope.interface import Interface
        EXPECTED = '\n\n'.join([
            "``IHasMethod``",
            " This interface has a method.",
            " Attributes:",
            " Methods:",
            "  ``aMethod(first, second, *rest)`` -- no documentation",
            ""
        ])
        class IHasMethod(Interface):
            """ This interface has a method.
            """
            def aMethod(first, second, *rest):
                pass

        self.assertEqual(self._callFUT(IHasMethod), EXPECTED) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:19,代碼來源:test_document.py


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