本文整理汇总了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)
示例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
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)