aboutsummaryrefslogtreecommitdiffstats
path: root/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests
diff options
context:
space:
mode:
Diffstat (limited to 'lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests')
-rw-r--r--lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/__init__.py13
-rw-r--r--lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/dummy.py22
-rw-r--r--lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/foodforthought.txt61
-rw-r--r--lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/ifoo.py26
-rw-r--r--lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/m1.py21
-rw-r--r--lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/m2.py15
-rw-r--r--lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/odd.py129
-rw-r--r--lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_adapter.py412
-rw-r--r--lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_advice.py185
-rw-r--r--lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_declarations.py428
-rw-r--r--lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_document.py69
-rw-r--r--lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_element.py41
-rw-r--r--lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_interface.py473
-rw-r--r--lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_odd_declarations.py216
-rw-r--r--lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_sorting.py55
-rw-r--r--lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_verify.py200
-rw-r--r--lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/unitfixtures.py140
17 files changed, 0 insertions, 2506 deletions
diff --git a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/__init__.py b/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/__init__.py
deleted file mode 100644
index 1cf24e65..00000000
--- a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/__init__.py
+++ /dev/null
@@ -1,13 +0,0 @@
-import os
-import unittest
-
-def additional_tests():
- suites = unittest.TestSuite()
- for file in os.listdir(os.path.dirname(__file__)):
- if file.endswith('.py') and file!='__init__.py':
- name = os.path.splitext(file)[0]
- module = __import__('.'.join((__name__, name)), globals(),
- locals(), [name])
- if hasattr(module, 'test_suite'):
- suites.addTests(module.test_suite())
- return suites
diff --git a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/dummy.py b/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/dummy.py
deleted file mode 100644
index f5564da3..00000000
--- a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/dummy.py
+++ /dev/null
@@ -1,22 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Dummy Module
-"""
-from zope.interface import moduleProvides
-from zope.interface.tests.ifoo import IFoo
-
-moduleProvides(IFoo)
-
-def bar(baz):
- pass
diff --git a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/foodforthought.txt b/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/foodforthought.txt
deleted file mode 100644
index 45d961be..00000000
--- a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/foodforthought.txt
+++ /dev/null
@@ -1,61 +0,0 @@
-================================
-Food-based subscription examples
-================================
-
-
-This file gives more subscription examples using a cooking-based example::
-
- >>> from zope.interface.adapter import AdapterRegistry
- >>> registry = AdapterRegistry()
-
- >>> import zope.interface
- >>> class IAnimal(zope.interface.Interface):
- ... pass
- >>> class IPoultry(IAnimal):
- ... pass
- >>> class IChicken(IPoultry):
- ... pass
- >>> class ISeafood(IAnimal):
- ... pass
-
-Adapting to some other interface for which there is no
-subscription adapter returns an empty sequence::
-
- >>> class IRecipe(zope.interface.Interface):
- ... pass
- >>> class ISausages(IRecipe):
- ... pass
- >>> class INoodles(IRecipe):
- ... pass
- >>> class IKFC(IRecipe):
- ... pass
-
- >>> list(registry.subscriptions([IPoultry], IRecipe))
- []
-
-unless we define a subscription::
-
- >>> registry.subscribe([IAnimal], ISausages, 'sausages')
- >>> list(registry.subscriptions([IPoultry], ISausages))
- ['sausages']
-
-And define another subscription adapter::
-
- >>> registry.subscribe([IPoultry], INoodles, 'noodles')
- >>> meals = list(registry.subscriptions([IPoultry], IRecipe))
- >>> meals.sort()
- >>> meals
- ['noodles', 'sausages']
-
- >>> registry.subscribe([IChicken], IKFC, 'kfc')
- >>> meals = list(registry.subscriptions([IChicken], IRecipe))
- >>> meals.sort()
- >>> meals
- ['kfc', 'noodles', 'sausages']
-
-And the answer for poultry hasn't changed::
-
- >>> meals = list(registry.subscriptions([IPoultry], IRecipe))
- >>> meals.sort()
- >>> meals
- ['noodles', 'sausages']
diff --git a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/ifoo.py b/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/ifoo.py
deleted file mode 100644
index 29a78779..00000000
--- a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/ifoo.py
+++ /dev/null
@@ -1,26 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""IFoo test module
-"""
-from zope.interface import Interface
-
-class IFoo(Interface):
- """
- Dummy interface for unit tests.
- """
-
- def bar(baz):
- """
- Just a note.
- """
diff --git a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/m1.py b/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/m1.py
deleted file mode 100644
index d311fb40..00000000
--- a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/m1.py
+++ /dev/null
@@ -1,21 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Test module that declares an interface
-"""
-from zope.interface import Interface, moduleProvides
-
-class I1(Interface): pass
-class I2(Interface): pass
-
-moduleProvides(I1, I2)
diff --git a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/m2.py b/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/m2.py
deleted file mode 100644
index 511cd9ce..00000000
--- a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/m2.py
+++ /dev/null
@@ -1,15 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Test module that doesn't declare an interface
-"""
diff --git a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/odd.py b/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/odd.py
deleted file mode 100644
index 04ffa31f..00000000
--- a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/odd.py
+++ /dev/null
@@ -1,129 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Odd meta class that doesn't subclass type.
-
-This is used for testing support for ExtensionClass in new interfaces.
-
- >>> class A(object):
- ... __metaclass__ = MetaClass
- ... a = 1
- ...
- >>> A.__name__
- 'A'
- >>> A.__bases__ == (object,)
- True
- >>> class B(object):
- ... __metaclass__ = MetaClass
- ... b = 1
- ...
- >>> class C(A, B): pass
- ...
- >>> C.__name__
- 'C'
- >>> int(C.__bases__ == (A, B))
- 1
- >>> a = A()
- >>> aa = A()
- >>> a.a
- 1
- >>> aa.a
- 1
- >>> aa.a = 2
- >>> a.a
- 1
- >>> aa.a
- 2
- >>> c = C()
- >>> c.a
- 1
- >>> c.b
- 1
- >>> c.b = 2
- >>> c.b
- 2
- >>> C.c = 1
- >>> c.c
- 1
- >>> import sys
- >>> if sys.version[0] == '2': # This test only makes sense under Python 2.x
- ... from types import ClassType
- ... assert not isinstance(C, (type, ClassType))
-
- >>> int(C.__class__.__class__ is C.__class__)
- 1
-"""
-
-# class OddClass is an odd meta class
-
-class MetaMetaClass(type):
-
- def __getattribute__(self, name):
- if name == '__class__':
- return self
- return type.__getattribute__(self, name)
-
-
-class MetaClass(object):
- """Odd classes
- """
- __metaclass__ = MetaMetaClass
-
- def __init__(self, name, bases, dict):
- self.__name__ = name
- self.__bases__ = bases
- self.__dict__.update(dict)
-
- def __call__(self):
- return OddInstance(self)
-
- def __getattr__(self, name):
- for b in self.__bases__:
- v = getattr(b, name, self)
- if v is not self:
- return v
- raise AttributeError(name)
-
- def __repr__(self):
- return "<odd class %s at %s>" % (self.__name__, hex(id(self)))
-
-class OddInstance(object):
-
- def __init__(self, cls):
- self.__dict__['__class__'] = cls
-
- def __getattribute__(self, name):
- dict = object.__getattribute__(self, '__dict__')
- if name == '__dict__':
- return dict
- v = dict.get(name, self)
- if v is not self:
- return v
- return getattr(dict['__class__'], name)
-
- def __setattr__(self, name, v):
- self.__dict__[name] = v
-
- def __delattr__(self, name):
- del self.__dict__[name]
-
- def __repr__(self):
- return "<odd %s instance at %s>" % (
- self.__class__.__name__, hex(id(self)))
-
-
-
-# DocTest:
-if __name__ == "__main__":
- import doctest, __main__
- doctest.testmod(__main__, isprivate=lambda *a: False)
diff --git a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_adapter.py b/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_adapter.py
deleted file mode 100644
index 30a85982..00000000
--- a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_adapter.py
+++ /dev/null
@@ -1,412 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Adapter registry tests
-"""
-import doctest
-import unittest
-import zope.interface
-from zope.interface.adapter import AdapterRegistry
-
-
-class IF0(zope.interface.Interface):
- pass
-class IF1(IF0):
- pass
-
-class IB0(zope.interface.Interface):
- pass
-class IB1(IB0):
- pass
-
-class IR0(zope.interface.Interface):
- pass
-class IR1(IR0):
- pass
-
-def test_multi_adapter_get_best_match():
- """
- >>> registry = AdapterRegistry()
-
- >>> class IB2(IB0):
- ... pass
- >>> class IB3(IB2, IB1):
- ... pass
- >>> class IB4(IB1, IB2):
- ... pass
-
- >>> registry.register([None, IB1], IR0, '', 'A1')
- >>> registry.register([None, IB0], IR0, '', 'A0')
- >>> registry.register([None, IB2], IR0, '', 'A2')
-
- >>> registry.lookup((IF1, IB1), IR0, '')
- 'A1'
- >>> registry.lookup((IF1, IB2), IR0, '')
- 'A2'
- >>> registry.lookup((IF1, IB0), IR0, '')
- 'A0'
- >>> registry.lookup((IF1, IB3), IR0, '')
- 'A2'
- >>> registry.lookup((IF1, IB4), IR0, '')
- 'A1'
- """
-
-def test_multi_adapter_lookupAll_get_best_matches():
- """
- >>> registry = AdapterRegistry()
-
- >>> class IB2(IB0):
- ... pass
- >>> class IB3(IB2, IB1):
- ... pass
- >>> class IB4(IB1, IB2):
- ... pass
-
- >>> registry.register([None, IB1], IR0, '', 'A1')
- >>> registry.register([None, IB0], IR0, '', 'A0')
- >>> registry.register([None, IB2], IR0, '', 'A2')
-
- >>> tuple(registry.lookupAll((IF1, IB1), IR0))[0][1]
- 'A1'
- >>> tuple(registry.lookupAll((IF1, IB2), IR0))[0][1]
- 'A2'
- >>> tuple(registry.lookupAll((IF1, IB0), IR0))[0][1]
- 'A0'
- >>> tuple(registry.lookupAll((IF1, IB3), IR0))[0][1]
- 'A2'
- >>> tuple(registry.lookupAll((IF1, IB4), IR0))[0][1]
- 'A1'
- """
-
-
-def test_multi_adapter_w_default():
- """
- >>> registry = AdapterRegistry()
-
- >>> registry.register([None, None], IB1, 'bob', 'A0')
-
- >>> registry.lookup((IF1, IR1), IB0, 'bob')
- 'A0'
-
- >>> registry.register([None, IR0], IB1, 'bob', 'A1')
-
- >>> registry.lookup((IF1, IR1), IB0, 'bob')
- 'A1'
-
- >>> registry.lookup((IF1, IR1), IB0, 'bruce')
-
- >>> registry.register([None, IR1], IB1, 'bob', 'A2')
- >>> registry.lookup((IF1, IR1), IB0, 'bob')
- 'A2'
- """
-
-def test_multi_adapter_w_inherited_and_multiple_registrations():
- """
- >>> registry = AdapterRegistry()
-
- >>> class IX(zope.interface.Interface):
- ... pass
-
- >>> registry.register([IF0, IR0], IB1, 'bob', 'A1')
- >>> registry.register([IF1, IX], IB1, 'bob', 'AX')
-
- >>> registry.lookup((IF1, IR1), IB0, 'bob')
- 'A1'
- """
-
-def test_named_adapter_with_default():
- """Query a named simple adapter
-
- >>> registry = AdapterRegistry()
-
- If we ask for a named adapter, we won't get a result unless there
- is a named adapter, even if the object implements the interface:
-
- >>> registry.lookup([IF1], IF0, 'bob')
-
- >>> registry.register([None], IB1, 'bob', 'A1')
- >>> registry.lookup([IF1], IB0, 'bob')
- 'A1'
-
- >>> registry.lookup([IF1], IB0, 'bruce')
-
- >>> registry.register([None], IB0, 'bob', 'A2')
- >>> registry.lookup([IF1], IB0, 'bob')
- 'A2'
- """
-
-def test_multi_adapter_gets_closest_provided():
- """
- >>> registry = AdapterRegistry()
- >>> registry.register([IF1, IR0], IB0, 'bob', 'A1')
- >>> registry.register((IF1, IR0), IB1, 'bob', 'A2')
- >>> registry.lookup((IF1, IR1), IB0, 'bob')
- 'A1'
-
- >>> registry = AdapterRegistry()
- >>> registry.register([IF1, IR0], IB1, 'bob', 'A2')
- >>> registry.register([IF1, IR0], IB0, 'bob', 'A1')
- >>> registry.lookup([IF1, IR0], IB0, 'bob')
- 'A1'
-
- >>> registry = AdapterRegistry()
- >>> registry.register([IF1, IR0], IB0, 'bob', 'A1')
- >>> registry.register([IF1, IR1], IB1, 'bob', 'A2')
- >>> registry.lookup([IF1, IR1], IB0, 'bob')
- 'A2'
-
- >>> registry = AdapterRegistry()
- >>> registry.register([IF1, IR1], IB1, 'bob', 2)
- >>> registry.register([IF1, IR0], IB0, 'bob', 1)
- >>> registry.lookup([IF1, IR1], IB0, 'bob')
- 2
- """
-
-def test_multi_adapter_check_non_default_dont_hide_default():
- """
- >>> registry = AdapterRegistry()
-
- >>> class IX(zope.interface.Interface):
- ... pass
-
-
- >>> registry.register([None, IR0], IB0, 'bob', 1)
- >>> registry.register([IF1, IX], IB0, 'bob', 2)
- >>> registry.lookup([IF1, IR1], IB0, 'bob')
- 1
- """
-
-def test_adapter_hook_with_factory_producing_None():
- """
- >>> registry = AdapterRegistry()
- >>> default = object()
-
- >>> class Object1(object):
- ... zope.interface.implements(IF0)
- >>> class Object2(object):
- ... zope.interface.implements(IF0)
-
- >>> def factory(context):
- ... if isinstance(context, Object1):
- ... return 'adapter'
- ... return None
-
- >>> registry.register([IF0], IB0, '', factory)
-
- >>> registry.adapter_hook(IB0, Object1())
- 'adapter'
- >>> registry.adapter_hook(IB0, Object2()) is None
- True
- >>> registry.adapter_hook(IB0, Object2(), default=default) is default
- True
- """
-
-def test_adapter_registry_update_upon_interface_bases_change():
- """
- Let's first create a adapter registry and a simple adaptation hook:
-
- >>> globalRegistry = AdapterRegistry()
-
- >>> def _hook(iface, ob, lookup=globalRegistry.lookup1):
- ... factory = lookup(zope.interface.providedBy(ob), iface)
- ... if factory is None:
- ... return None
- ... else:
- ... return factory(ob)
-
- >>> zope.interface.interface.adapter_hooks.append(_hook)
-
- Now we create some interfaces and an implementation:
-
- >>> class IX(zope.interface.Interface):
- ... pass
-
- >>> class IY(zope.interface.Interface):
- ... pass
-
- >>> class X(object):
- ... pass
-
- >>> class Y(object):
- ... zope.interface.implements(IY)
- ... def __init__(self, original):
- ... self.original=original
-
- and register an adapter:
-
- >>> globalRegistry.register((IX,), IY, '', Y)
-
- at first, we still expect the adapter lookup from `X` to `IY` to fail:
-
- >>> IY(X()) #doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
- Traceback (most recent call last):
- ...
- TypeError: ('Could not adapt',
- <zope.interface.tests.test_adapter.X object at ...>,
- <InterfaceClass zope.interface.tests.test_adapter.IY>)
-
- But after we declare an interface on the class `X`, it should pass:
-
- >>> zope.interface.classImplementsOnly(X, IX)
-
- >>> IY(X()) #doctest: +ELLIPSIS
- <zope.interface.tests.test_adapter.Y object at ...>
-
- >>> hook = zope.interface.interface.adapter_hooks.pop()
- """
-
-
-def test_changing_declarations():
- """
-
- If we change declarations for a class, those adapter lookup should
- eflect the changes:
-
- >>> class I1(zope.interface.Interface):
- ... pass
- >>> class I2(zope.interface.Interface):
- ... pass
-
- >>> registry = AdapterRegistry()
- >>> registry.register([I1], I2, '', 42)
-
- >>> class C:
- ... pass
-
- >>> registry.lookup([zope.interface.implementedBy(C)], I2, '')
-
- >>> zope.interface.classImplements(C, I1)
-
- >>> registry.lookup([zope.interface.implementedBy(C)], I2, '')
- 42
- """
-
-def test_correct_multi_adapter_lookup():
- """
- >>> registry = AdapterRegistry()
- >>> registry.register([IF0, IB1], IR0, '', 'A01')
- >>> registry.register([IF1, IB0], IR0, '', 'A10')
- >>> registry.lookup((IF1, IB1), IR0, '')
- 'A10'
- """
-
-def test_duplicate_bases():
- """
-There was a bug that caused problems if a spec had multiple bases:
-
- >>> class I(zope.interface.Interface):
- ... pass
- >>> class I2(I, I):
- ... pass
- >>> registry = AdapterRegistry()
- >>> registry.register([I2], IR0, 'x', 'X')
- >>> registry.lookup((I2, ), IR0, 'x')
- 'X'
- >>> registry.register([I2], IR0, 'y', 'Y')
- >>> registry.lookup((I2, ), IR0, 'x')
- 'X'
- >>> registry.lookup((I2, ), IR0, 'y')
- 'Y'
-"""
-
-def test_register_objects_with_cmp():
- """
- The registry should never use == as that will tend to fail when
- objects are picky about what they are compared with:
-
- >>> class Picky:
- ... def __cmp__(self, other):
- ... raise TypeError("I\'m too picky for comparison!")
- >>> class I(zope.interface.Interface):
- ... pass
- >>> class I2(I, I):
- ... pass
-
- >>> registry = AdapterRegistry()
- >>> picky = Picky()
- >>> registry.register([I2], IR0, '', picky)
- >>> registry.unregister([I2], IR0, '', picky)
-
- >>> registry.subscribe([I2], IR0, picky)
- >>> registry.unsubscribe([I2], IR0, picky)
-
- """
-
-def test_unregister_cleans_up_empties():
- """
- >>> class I(zope.interface.Interface):
- ... pass
- >>> class IP(zope.interface.Interface):
- ... pass
- >>> class C(object):
- ... pass
-
- >>> registry = AdapterRegistry()
-
- >>> registry.register([], IP, '', C)
- >>> registry.register([I], IP, '', C)
- >>> registry.register([I], IP, 'name', C)
- >>> registry.register([I, I], IP, '', C)
- >>> len(registry._adapters)
- 3
- >>> map(len, registry._adapters)
- [1, 1, 1]
-
- >>> registry.unregister([], IP, '', C)
- >>> registry.unregister([I], IP, '', C)
- >>> registry.unregister([I], IP, 'name', C)
- >>> registry.unregister([I, I], IP, '', C)
- >>> registry._adapters
- []
-
- """
-
-def test_unsubscribe_cleans_up_empties():
- """
- >>> class I1(zope.interface.Interface):
- ... pass
- >>> class I2(zope.interface.Interface):
- ... pass
- >>> class IP(zope.interface.Interface):
- ... pass
-
- >>> registry = AdapterRegistry()
- >>> def handler(event):
- ... pass
-
- >>> registry.subscribe([I1], I1, handler)
- >>> registry.subscribe([I2], I1, handler)
- >>> len(registry._subscribers)
- 2
- >>> map(len, registry._subscribers)
- [0, 2]
-
- >>> registry.unsubscribe([I1], I1, handler)
- >>> registry.unsubscribe([I2], I1, handler)
- >>> registry._subscribers
- []
-
- """
-
-
-def test_suite():
- return unittest.TestSuite((
- doctest.DocFileSuite('../adapter.txt', '../adapter.ru.txt',
- '../human.txt', '../human.ru.txt',
- 'foodforthought.txt',
- globs={'__name__': '__main__'}),
- doctest.DocTestSuite(),
- ))
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
diff --git a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_advice.py b/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_advice.py
deleted file mode 100644
index f21252e0..00000000
--- a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_advice.py
+++ /dev/null
@@ -1,185 +0,0 @@
-
-##############################################################################
-#
-# Copyright (c) 2003 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Tests for advice
-
-This module was adapted from 'protocols.tests.advice', part of the Python
-Enterprise Application Kit (PEAK). Please notify the PEAK authors
-(pje@telecommunity.com and tsarna@sarna.org) if bugs are found or
-Zope-specific changes are required, so that the PEAK version of this module
-can be kept in sync.
-
-PEAK is a Python application framework that interoperates with (but does
-not require) Zope 3 and Twisted. It provides tools for manipulating UML
-models, object-relational persistence, aspect-oriented programming, and more.
-Visit the PEAK home page at http://peak.telecommunity.com for more information.
-"""
-
-import unittest
-from unittest import TestCase, makeSuite, TestSuite
-from zope.interface.advice import addClassAdvisor, determineMetaclass
-from zope.interface.advice import getFrameInfo
-import sys
-
-def ping(log, value):
-
- def pong(klass):
- log.append((value,klass))
- return [klass]
-
- addClassAdvisor(pong)
-
-try:
- from types import ClassType
-
- class ClassicClass:
- __metaclass__ = ClassType
- classLevelFrameInfo = getFrameInfo(sys._getframe())
-except ImportError:
- pass
-
-class NewStyleClass:
- __metaclass__ = type
- classLevelFrameInfo = getFrameInfo(sys._getframe())
-
-moduleLevelFrameInfo = getFrameInfo(sys._getframe())
-
-class FrameInfoTest(TestCase):
-
- classLevelFrameInfo = getFrameInfo(sys._getframe())
-
- def checkModuleInfo(self):
- kind, module, f_locals, f_globals = moduleLevelFrameInfo
- self.assertEquals(kind, "module")
- for d in module.__dict__, f_locals, f_globals:
- self.assert_(d is globals())
-
- def checkClassicClassInfo(self):
- kind, module, f_locals, f_globals = ClassicClass.classLevelFrameInfo
- self.assertEquals(kind, "class")
-
- self.assert_(f_locals is ClassicClass.__dict__) # ???
- for d in module.__dict__, f_globals:
- self.assert_(d is globals())
-
- def checkNewStyleClassInfo(self):
- kind, module, f_locals, f_globals = NewStyleClass.classLevelFrameInfo
- self.assertEquals(kind, "class")
-
- for d in module.__dict__, f_globals:
- self.assert_(d is globals())
-
- def checkCallInfo(self):
- kind, module, f_locals, f_globals = getFrameInfo(sys._getframe())
- self.assertEquals(kind, "function call")
- self.assert_(f_locals is locals()) # ???
- for d in module.__dict__, f_globals:
- self.assert_(d is globals())
-
-
-class AdviceTests(TestCase):
-
- def checkOrder(self):
- log = []
- class Foo(object):
- ping(log, 1)
- ping(log, 2)
- ping(log, 3)
-
- # Strip the list nesting
- for i in 1,2,3:
- self.assert_(isinstance(Foo, list))
- Foo, = Foo
-
- self.assertEquals(log, [(1, Foo), (2, [Foo]), (3, [[Foo]])])
-
- def TODOcheckOutside(self):
- # Disabled because the check does not work with doctest tests.
- try:
- ping([], 1)
- except SyntaxError:
- pass
- else:
- raise AssertionError(
- "Should have detected advice outside class body"
- )
-
- def checkDoubleType(self):
- if sys.hexversion >= 0x02030000:
- return # you can't duplicate bases in 2.3
- class aType(type,type):
- ping([],1)
- aType, = aType
- self.assert_(aType.__class__ is type)
-
- def checkSingleExplicitMeta(self):
-
- class M(type):
- pass
-
- class C(M):
- __metaclass__ = M
- ping([],1)
-
- C, = C
- self.assert_(C.__class__ is M)
-
-
- def checkMixedMetas(self):
-
- class M1(type): pass
- class M2(type): pass
-
- class B1: __metaclass__ = M1
- class B2: __metaclass__ = M2
-
- try:
- class C(B1,B2):
- ping([],1)
- except TypeError:
- pass
- else:
- raise AssertionError("Should have gotten incompatibility error")
-
- class M3(M1,M2): pass
-
- class C(B1,B2):
- __metaclass__ = M3
- ping([],1)
-
- self.assert_(isinstance(C,list))
- C, = C
- self.assert_(isinstance(C,M3))
-
- def checkMetaOfClass(self):
-
- class metameta(type):
- pass
-
- class meta(type):
- __metaclass__ = metameta
-
- self.assertEquals(determineMetaclass((meta, type)), metameta)
-
-TestClasses = (AdviceTests, FrameInfoTest)
-
-def test_suite():
- if sys.version[0] == '2':
- return TestSuite([makeSuite(t,'check') for t in TestClasses])
- else:
- # Advise metaclasses doesn't work in Python 3
- return TestSuite([])
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
diff --git a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_declarations.py b/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_declarations.py
deleted file mode 100644
index 6c8455c7..00000000
--- a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_declarations.py
+++ /dev/null
@@ -1,428 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Test the new API for making and checking interface declarations
-"""
-import doctest
-import unittest
-
-from zope.interface import Interface, implements
-from zope.interface import directlyProvides, providedBy
-from zope.interface import classImplements, implementedBy, implementsOnly
-
-class I1(Interface): pass
-class I2(Interface): pass
-class I3(Interface): pass
-class I4(Interface): pass
-class I5(Interface): pass
-
-class A(object):
- implements(I1)
-class B(object):
- implements(I2)
-class C(A, B):
- implements(I3)
-
-class COnly(A, B):
- implementsOnly(I3)
-
-class COnly_old(A, B):
- __implemented__ = I3
-
-class D(COnly):
- implements(I5)
-
-def test_ObjectSpecification_Simple():
- """
- >>> c = C()
- >>> directlyProvides(c, I4)
- >>> [i.__name__ for i in providedBy(c)]
- ['I4', 'I3', 'I1', 'I2']
- """
-
-def test_ObjectSpecification_Simple_w_only():
- """
- >>> c = COnly()
- >>> directlyProvides(c, I4)
- >>> [i.__name__ for i in providedBy(c)]
- ['I4', 'I3']
- """
-
-def test_ObjectSpecification_Simple_old_style():
- """
- >>> c = COnly_old()
- >>> directlyProvides(c, I4)
- >>> [i.__name__ for i in providedBy(c)]
- ['I4', 'I3']
- """
-
-
-class Test(unittest.TestCase):
-
- # Note that most of the tests are in the doc strings of the
- # declarations module.
-
- def test_backward_compat(self):
-
- class C1(object): __implemented__ = I1
- class C2(C1): __implemented__ = I2, I5
- class C3(C2): __implemented__ = I3, C2.__implemented__
-
- self.assert_(C3.__implemented__.__class__ is tuple)
-
- self.assertEqual(
- [i.getName() for i in providedBy(C3())],
- ['I3', 'I2', 'I5'],
- )
-
- class C4(C3):
- implements(I4)
-
- self.assertEqual(
- [i.getName() for i in providedBy(C4())],
- ['I4', 'I3', 'I2', 'I5'],
- )
-
- self.assertEqual(
- [i.getName() for i in C4.__implemented__],
- ['I4', 'I3', 'I2', 'I5'],
- )
-
- # Note that C3.__implemented__ should now be a sequence of interfaces
- self.assertEqual(
- [i.getName() for i in C3.__implemented__],
- ['I3', 'I2', 'I5'],
- )
- self.failIf(C3.__implemented__.__class__ is tuple)
-
- def test_module(self):
- from zope.interface.tests import m1, m2
- #import zope.interface.tests.m2
- directlyProvides(m2,
- m1.I1,
- m1.I2,
- )
- self.assertEqual(list(providedBy(m1)),
- list(providedBy(m2)),
- )
-
- def test_builtins(self):
- # Setup
-
- intspec = implementedBy(int)
- olddeclared = intspec.declared
-
- classImplements(int, I1)
- class myint(int):
- implements(I2)
-
- x = 42
- self.assertEqual([i.getName() for i in providedBy(x)],
- ['I1'])
-
- x = myint(42)
- directlyProvides(x, I3)
- self.assertEqual([i.getName() for i in providedBy(x)],
- ['I3', 'I2', 'I1'])
-
- # cleanup
- intspec.declared = olddeclared
- classImplements(int)
-
- x = 42
- self.assertEqual([i.getName() for i in providedBy(x)],
- [])
-
-
-def test_signature_w_no_class_interfaces():
- """
- >>> from zope.interface import *
- >>> class C(object):
- ... pass
- >>> c = C()
- >>> list(providedBy(c))
- []
-
- >>> class I(Interface):
- ... pass
- >>> directlyProvides(c, I)
- >>> list(providedBy(c)) == list(directlyProvidedBy(c))
- 1
- """
-
-def test_classImplement_on_deeply_nested_classes():
- """This test is in response to a bug found, which is why it's a bit
- contrived
-
- >>> from zope.interface import *
- >>> class B1(object):
- ... pass
- >>> class B2(B1):
- ... pass
- >>> class B3(B2):
- ... pass
- >>> class D(object):
- ... implements()
- >>> class S(B3, D):
- ... implements()
-
- This failed due to a bug in the code for finding __providedBy__
- descriptors for old-style classes.
-
- """
-
-def test_pickle_provides_specs():
- """
- >>> from pickle import dumps, loads
- >>> a = A()
- >>> I2.providedBy(a)
- 0
- >>> directlyProvides(a, I2)
- >>> I2.providedBy(a)
- 1
- >>> a2 = loads(dumps(a))
- >>> I2.providedBy(a2)
- 1
-
- """
-
-def test_that_we_dont_inherit_class_provides():
- """
- >>> from zope.interface import classProvides
- >>> class X(object):
- ... classProvides(I1)
- >>> class Y(X):
- ... pass
- >>> [i.__name__ for i in X.__provides__]
- ['I1']
- >>> Y.__provides__
- Traceback (most recent call last):
- ...
- AttributeError: __provides__
-
- """
-
-def test_that_we_dont_inherit_provides_optimizations():
- """
-
- When we make a declaration for a class, we install a __provides__
- descriptors that provides a default for instances that don't have
- instance-specific declarations:
-
- >>> class A(object):
- ... implements(I1)
-
- >>> class B(object):
- ... implements(I2)
-
- >>> [i.__name__ for i in A().__provides__]
- ['I1']
- >>> [i.__name__ for i in B().__provides__]
- ['I2']
-
- But it's important that we don't use this for subclasses without
- declarations. This would cause incorrect results:
-
- >>> class X(A, B):
- ... pass
-
- >>> X().__provides__
- Traceback (most recent call last):
- ...
- AttributeError: __provides__
-
- However, if we "induce" a declaration, by calling implementedBy
- (even indirectly through providedBy):
-
- >>> [i.__name__ for i in providedBy(X())]
- ['I1', 'I2']
-
-
- then the optimization will work:
-
- >>> [i.__name__ for i in X().__provides__]
- ['I1', 'I2']
-
- """
-
-def test_classProvides_before_implements():
- """Special descriptor for class __provides__
-
- The descriptor caches the implementedBy info, so that
- we can get declarations for objects without instance-specific
- interfaces a bit quicker.
-
- For example::
-
- >>> from zope.interface import Interface, classProvides
- >>> class IFooFactory(Interface):
- ... pass
- >>> class IFoo(Interface):
- ... pass
- >>> class C(object):
- ... classProvides(IFooFactory)
- ... implements(IFoo)
- >>> [i.getName() for i in C.__provides__]
- ['IFooFactory']
-
- >>> [i.getName() for i in C().__provides__]
- ['IFoo']
- """
-
-def test_getting_spec_for_proxied_builtin_class():
- """
-
- In general, we should be able to get a spec
- for a proxied class if someone has declared or
- asked for a spec before.
-
- We don't want to depend on proxies in this (zope.interface)
- package, but we do want to work with proxies. Proxies have the
- effect that a class's __dict__ cannot be gotten. Further, for
- built-in classes, we can't save, and thus, cannot get, any class
- attributes. We'll emulate this by treating a plain object as a class:
-
- >>> cls = object()
-
- We'll create an implements specification:
-
- >>> import zope.interface.declarations
- >>> impl = zope.interface.declarations.Implements(I1, I2)
-
- Now, we'll emulate a declaration for a built-in type by putting
- it in BuiltinImplementationSpecifications:
-
- >>> zope.interface.declarations.BuiltinImplementationSpecifications[
- ... cls] = impl
-
- Now, we should be able to get it back:
-
- >>> implementedBy(cls) is impl
- True
-
- Of course, we don't want to leave it there. :)
-
- >>> del zope.interface.declarations.BuiltinImplementationSpecifications[
- ... cls]
-
- """
-
-def test_declaration_get():
- """
- We can get definitions from a declaration:
-
- >>> import zope.interface
- >>> class I1(zope.interface.Interface):
- ... a11 = zope.interface.Attribute('a11')
- ... a12 = zope.interface.Attribute('a12')
- >>> class I2(zope.interface.Interface):
- ... a21 = zope.interface.Attribute('a21')
- ... a22 = zope.interface.Attribute('a22')
- ... a12 = zope.interface.Attribute('a212')
- >>> class I11(I1):
- ... a11 = zope.interface.Attribute('a111')
-
- >>> decl = zope.interface.Declaration(I11, I2)
- >>> decl.get('a11') is I11.get('a11')
- True
- >>> decl.get('a12') is I1.get('a12')
- True
- >>> decl.get('a21') is I2.get('a21')
- True
- >>> decl.get('a22') is I2.get('a22')
- True
- >>> decl.get('a')
- >>> decl.get('a', 42)
- 42
-
- We get None even with no interfaces:
-
- >>> decl = zope.interface.Declaration()
- >>> decl.get('a11')
- >>> decl.get('a11', 42)
- 42
-
- We get new data if e change interface bases:
-
- >>> decl.__bases__ = I11, I2
- >>> decl.get('a11') is I11.get('a11')
- True
- """
-
-def test_classImplements_after_classImplementsOnly_issue_402():
- """http://www.zope.org/Collectors/Zope3-dev/402
-
->>> from zope.interface import *
->>> class I1(Interface):
-... pass
->>> class I2(Interface):
-... pass
->>> class C:
-... implements(I1)
->>> class C2:
-... implementsOnly(I2)
->>> class I3(Interface):
-... pass
-
->>> [i.__name__ for i in providedBy(C2()).__iro__]
-['I2', 'Interface']
-
->>> classImplements(C2, I3)
->>> [i.__name__ for i in providedBy(C2()).__iro__]
-['I2', 'I3', 'Interface']
-
->>> class I4(Interface):
-... pass
->>> classImplements(C2, I4)
->>> [i.__name__ for i in providedBy(C2()).__iro__]
-['I2', 'I3', 'I4', 'Interface']
-
-
-"""
-
-def test_picklability_of_implements_specifications():
- """
-
- Sometimes, we need to pickle implements specs. We should be able
- to do so as long as the class is picklable.
-
- >>> import pickle
- >>> pickle.loads(pickle.dumps(implementedBy(C))) is implementedBy(C)
- True
-
-
- """
-
-def test_provided_by_with_slots():
- """
-
- This is an edge case: if the __slots__ of a class contain '__provides__',
- using providedBy() on that class should still work (this occurs, for
- example, when providing an adapter for a concrete class.)
-
- >>> import zope.interface
- >>> class Slotted(object):
- ... __slots__ = ('__provides__')
- >>> class IFoo(zope.interface.Interface):
- ... pass
- >>> IFoo.providedBy(Slotted)
- False
-
- """
-
-def test_suite():
- return unittest.TestSuite((
- unittest.makeSuite(Test),
- doctest.DocTestSuite("zope.interface.declarations"),
- doctest.DocTestSuite(),
- ))
diff --git a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_document.py b/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_document.py
deleted file mode 100644
index a2653b3f..00000000
--- a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_document.py
+++ /dev/null
@@ -1,69 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Documentation tests.
-"""
-from unittest import TestCase, main, makeSuite
-
-from zope.interface import Interface, Attribute
-
-class Test(TestCase):
-
- def testBlech(self):
- from zope.interface.document import asStructuredText
-
- self.assertEqual(asStructuredText(I2), '''\
-I2
-
- I2 doc
-
- This interface extends:
-
- o _I1
-
- Attributes:
-
- a1 -- no documentation
-
- a2 -- a2 doc
-
- Methods:
-
- f21() -- f21 doc
-
- f22() -- no documentation
-
- f23() -- f23 doc
-
-''')
-
-
-def test_suite():
- return makeSuite(Test)
-
-class _I1(Interface):
- def f11(): pass
- def f12(): pass
-
-class I2(_I1):
- "I2 doc"
-
- a1 = Attribute('a1')
- a2 = Attribute('a2', 'a2 doc')
-
- def f21(): "f21 doc"
- def f22(): pass
- def f23(): "f23 doc"
-
-if __name__=='__main__':
- main(defaultTest='test_suite')
diff --git a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_element.py b/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_element.py
deleted file mode 100644
index 66724a67..00000000
--- a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_element.py
+++ /dev/null
@@ -1,41 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Test Element meta-class.
-"""
-
-import unittest
-from zope.interface.interface import Element
-
-class TestElement(unittest.TestCase):
-
- def test_taggedValues(self):
- """Test that we can update tagged values of more than one element
- """
-
- e1 = Element("foo")
- e2 = Element("bar")
- e1.setTaggedValue("x", 1)
- e2.setTaggedValue("x", 2)
- self.assertEqual(e1.getTaggedValue("x"), 1)
- self.assertEqual(e2.getTaggedValue("x"), 2)
-
-
-def test_suite():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(TestElement))
- return suite
-
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
diff --git a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_interface.py b/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_interface.py
deleted file mode 100644
index 226e59c8..00000000
--- a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_interface.py
+++ /dev/null
@@ -1,473 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Test Interface implementation
-"""
-import doctest
-import unittest
-import sys
-
-class InterfaceTests(unittest.TestCase):
-
- def _makeDerivedInterface(self):
- from zope.interface import Interface
- from zope.interface import Attribute
- class _I1(Interface):
-
- a1 = Attribute("This is an attribute")
-
- def f11():
- pass
- def f12():
- pass
- f12.optional = 1
-
- class _I1_(_I1):
- pass
-
- class _I1__(_I1_):
- pass
-
- class _I2(_I1__):
- def f21():
- pass
- def f22():
- pass
- f23 = f22
-
- return _I2
-
- def testInterfaceSetOnAttributes(self):
- from zope.interface.tests.unitfixtures import FooInterface
- self.assertEqual(FooInterface['foobar'].interface,
- FooInterface)
- self.assertEqual(FooInterface['aMethod'].interface,
- FooInterface)
-
- def testClassImplements(self):
- from zope.interface.tests.unitfixtures import A
- from zope.interface.tests.unitfixtures import B
- from zope.interface.tests.unitfixtures import C
- from zope.interface.tests.unitfixtures import D
- from zope.interface.tests.unitfixtures import E
- from zope.interface.tests.unitfixtures import I1
- from zope.interface.tests.unitfixtures import I2
- from zope.interface.tests.unitfixtures import IC
- self.assert_(IC.implementedBy(C))
-
- self.assert_(I1.implementedBy(A))
- self.assert_(I1.implementedBy(B))
- self.assert_(not I1.implementedBy(C))
- self.assert_(I1.implementedBy(D))
- self.assert_(I1.implementedBy(E))
-
- self.assert_(not I2.implementedBy(A))
- self.assert_(I2.implementedBy(B))
- self.assert_(not I2.implementedBy(C))
-
- # No longer after interfacegeddon
- # self.assert_(not I2.implementedBy(D))
-
- self.assert_(not I2.implementedBy(E))
-
- def testUtil(self):
- from zope.interface import implementedBy
- from zope.interface import providedBy
- from zope.interface.tests.unitfixtures import A
- from zope.interface.tests.unitfixtures import B
- from zope.interface.tests.unitfixtures import C
- from zope.interface.tests.unitfixtures import I1
- from zope.interface.tests.unitfixtures import I2
- from zope.interface.tests.unitfixtures import IC
- self.assert_(IC in implementedBy(C))
- self.assert_(I1 in implementedBy(A))
- self.assert_(not I1 in implementedBy(C))
- self.assert_(I2 in implementedBy(B))
- self.assert_(not I2 in implementedBy(C))
-
- self.assert_(IC in providedBy(C()))
- self.assert_(I1 in providedBy(A()))
- self.assert_(not I1 in providedBy(C()))
- self.assert_(I2 in providedBy(B()))
- self.assert_(not I2 in providedBy(C()))
-
-
- def testObjectImplements(self):
- from zope.interface.tests.unitfixtures import A
- from zope.interface.tests.unitfixtures import B
- from zope.interface.tests.unitfixtures import C
- from zope.interface.tests.unitfixtures import D
- from zope.interface.tests.unitfixtures import E
- from zope.interface.tests.unitfixtures import I1
- from zope.interface.tests.unitfixtures import I2
- from zope.interface.tests.unitfixtures import IC
- self.assert_(IC.providedBy(C()))
-
- self.assert_(I1.providedBy(A()))
- self.assert_(I1.providedBy(B()))
- self.assert_(not I1.providedBy(C()))
- self.assert_(I1.providedBy(D()))
- self.assert_(I1.providedBy(E()))
-
- self.assert_(not I2.providedBy(A()))
- self.assert_(I2.providedBy(B()))
- self.assert_(not I2.providedBy(C()))
-
- # Not after interface geddon
- # self.assert_(not I2.providedBy(D()))
-
- self.assert_(not I2.providedBy(E()))
-
- def testDeferredClass(self):
- from zope.interface.tests.unitfixtures import A
- from zope.interface.exceptions import BrokenImplementation
- a = A()
- self.assertRaises(BrokenImplementation, a.ma)
-
-
- def testInterfaceExtendsInterface(self):
- from zope.interface.tests.unitfixtures import BazInterface
- from zope.interface.tests.unitfixtures import BarInterface
- from zope.interface.tests.unitfixtures import BobInterface
- from zope.interface.tests.unitfixtures import FunInterface
- self.assert_(BazInterface.extends(BobInterface))
- self.assert_(BazInterface.extends(BarInterface))
- self.assert_(BazInterface.extends(FunInterface))
- self.assert_(not BobInterface.extends(FunInterface))
- self.assert_(not BobInterface.extends(BarInterface))
- self.assert_(BarInterface.extends(FunInterface))
- self.assert_(not BarInterface.extends(BazInterface))
-
- def testVerifyImplementation(self):
- from zope.interface.verify import verifyClass
- from zope.interface import Interface
- from zope.interface.tests.unitfixtures import Foo
- from zope.interface.tests.unitfixtures import FooInterface
- from zope.interface.tests.unitfixtures import I1
- self.assert_(verifyClass(FooInterface, Foo))
- self.assert_(Interface.providedBy(I1))
-
- def test_names(self):
- iface = self._makeDerivedInterface()
- names = list(iface.names())
- names.sort()
- self.assertEqual(names, ['f21', 'f22', 'f23'])
- all = list(iface.names(all=True))
- all.sort()
- self.assertEqual(all, ['a1', 'f11', 'f12', 'f21', 'f22', 'f23'])
-
- def test_namesAndDescriptions(self):
- iface = self._makeDerivedInterface()
- names = [nd[0] for nd in iface.namesAndDescriptions()]
- names.sort()
- self.assertEqual(names, ['f21', 'f22', 'f23'])
- names = [nd[0] for nd in iface.namesAndDescriptions(1)]
- names.sort()
- self.assertEqual(names, ['a1', 'f11', 'f12', 'f21', 'f22', 'f23'])
-
- for name, d in iface.namesAndDescriptions(1):
- self.assertEqual(name, d.__name__)
-
- def test_getDescriptionFor(self):
- iface = self._makeDerivedInterface()
- self.assertEqual(iface.getDescriptionFor('f11').__name__, 'f11')
- self.assertEqual(iface.getDescriptionFor('f22').__name__, 'f22')
- self.assertEqual(iface.queryDescriptionFor('f33', self), self)
- self.assertRaises(KeyError, iface.getDescriptionFor, 'f33')
-
- def test___getitem__(self):
- iface = self._makeDerivedInterface()
- self.assertEqual(iface['f11'].__name__, 'f11')
- self.assertEqual(iface['f22'].__name__, 'f22')
- self.assertEqual(iface.get('f33', self), self)
- self.assertRaises(KeyError, iface.__getitem__, 'f33')
-
- def test___contains__(self):
- iface = self._makeDerivedInterface()
- self.failUnless('f11' in iface)
- self.failIf('f33' in iface)
-
- def test___iter__(self):
- iface = self._makeDerivedInterface()
- names = list(iter(iface))
- names.sort()
- self.assertEqual(names, ['a1', 'f11', 'f12', 'f21', 'f22', 'f23'])
-
- def testAttr(self):
- iface = self._makeDerivedInterface()
- description = iface.getDescriptionFor('a1')
- self.assertEqual(description.__name__, 'a1')
- self.assertEqual(description.__doc__, 'This is an attribute')
-
- def testFunctionAttributes(self):
- # Make sure function attributes become tagged values.
- from zope.interface import Interface
- class ITest(Interface):
- def method():
- pass
- method.optional = 1
-
- method = ITest['method']
- self.assertEqual(method.getTaggedValue('optional'), 1)
-
- def testInvariant(self):
- from zope.interface.exceptions import Invalid
- from zope.interface import directlyProvides
- from zope.interface.tests.unitfixtures import BarGreaterThanFoo
- from zope.interface.tests.unitfixtures import ifFooThenBar
- from zope.interface.tests.unitfixtures import IInvariant
- from zope.interface.tests.unitfixtures import InvariantC
- from zope.interface.tests.unitfixtures import ISubInvariant
- # set up
- o = InvariantC()
- directlyProvides(o, IInvariant)
- # a helper
- def errorsEqual(self, o, error_len, error_msgs, iface=None):
- if iface is None:
- iface = IInvariant
- self.assertRaises(Invalid, iface.validateInvariants, o)
- e = []
- try:
- iface.validateInvariants(o, e)
- except Invalid, error:
- self.assertEquals(error.args[0], e)
- else:
- self._assert(0) # validateInvariants should always raise
- # Invalid
- self.assertEquals(len(e), error_len)
- msgs = [error.args[0] for error in e]
- msgs.sort()
- for msg in msgs:
- self.assertEquals(msg, error_msgs.pop(0))
- # the tests
- self.assertEquals(IInvariant.getTaggedValue('invariants'),
- [ifFooThenBar])
- self.assertEquals(IInvariant.validateInvariants(o), None)
- o.bar = 27
- self.assertEquals(IInvariant.validateInvariants(o), None)
- o.foo = 42
- self.assertEquals(IInvariant.validateInvariants(o), None)
- del o.bar
- errorsEqual(self, o, 1, ['If Foo, then Bar!'])
- # nested interfaces with invariants:
- self.assertEquals(ISubInvariant.getTaggedValue('invariants'),
- [BarGreaterThanFoo])
- o = InvariantC()
- directlyProvides(o, ISubInvariant)
- o.foo = 42
- # even though the interface has changed, we should still only have one
- # error.
- errorsEqual(self, o, 1, ['If Foo, then Bar!'], ISubInvariant)
- # however, if we set foo to 0 (Boolean False) and bar to a negative
- # number then we'll get the new error
- o.foo = 2
- o.bar = 1
- errorsEqual(self, o, 1, ['Please, Boo MUST be greater than Foo!'],
- ISubInvariant)
- # and if we set foo to a positive number and boo to 0, we'll
- # get both errors!
- o.foo = 1
- o.bar = 0
- errorsEqual(self, o, 2, ['If Foo, then Bar!',
- 'Please, Boo MUST be greater than Foo!'],
- ISubInvariant)
- # for a happy ending, we'll make the invariants happy
- o.foo = 1
- o.bar = 2
- self.assertEquals(IInvariant.validateInvariants(o), None) # woohoo
- # now we'll do two invariants on the same interface,
- # just to make sure that a small
- # multi-invariant interface is at least minimally tested.
- o = InvariantC()
- directlyProvides(o, IInvariant)
- o.foo = 42
- old_invariants = IInvariant.getTaggedValue('invariants')
- invariants = old_invariants[:]
- invariants.append(BarGreaterThanFoo) # if you really need to mutate,
- # then this would be the way to do it. Probably a bad idea, though. :-)
- IInvariant.setTaggedValue('invariants', invariants)
- #
- # even though the interface has changed, we should still only have one
- # error.
- errorsEqual(self, o, 1, ['If Foo, then Bar!'])
- # however, if we set foo to 0 (Boolean False) and bar to a negative
- # number then we'll get the new error
- o.foo = 2
- o.bar = 1
- errorsEqual(self, o, 1, ['Please, Boo MUST be greater than Foo!'])
- # and if we set foo to a positive number and boo to 0, we'll
- # get both errors!
- o.foo = 1
- o.bar = 0
- errorsEqual(self, o, 2, ['If Foo, then Bar!',
- 'Please, Boo MUST be greater than Foo!'])
- # for another happy ending, we'll make the invariants happy again
- o.foo = 1
- o.bar = 2
- self.assertEquals(IInvariant.validateInvariants(o), None) # bliss
- # clean up
- IInvariant.setTaggedValue('invariants', old_invariants)
-
- def test___doc___element(self):
- from zope.interface import Interface
- from zope.interface import Attribute
- class I(Interface):
- "xxx"
-
- self.assertEqual(I.__doc__, "xxx")
- self.assertEqual(list(I), [])
-
- class I(Interface):
- "xxx"
-
- __doc__ = Attribute('the doc')
-
- self.assertEqual(I.__doc__, "")
- self.assertEqual(list(I), ['__doc__'])
-
- def testIssue228(self):
- from zope.interface import Interface
- # Test for http://collector.zope.org/Zope3-dev/228
- if sys.version[0] == '3':
- # No old style classes in Python 3, so the test becomes moot.
- return
- class I(Interface):
- "xxx"
- class Bad:
- __providedBy__ = None
- # Old style classes don't have a '__class__' attribute
- self.failUnlessRaises(AttributeError, I.providedBy, Bad)
-
- def test_comparison_with_None(self):
- from zope.interface import Interface
-
- class IEmpty(Interface):
- pass
-
- self.failUnless(IEmpty < None)
- self.failUnless(IEmpty <= None)
- self.failIf(IEmpty == None)
- self.failUnless(IEmpty != None)
- self.failIf(IEmpty >= None)
- self.failIf(IEmpty > None)
-
- self.failIf(None < IEmpty)
- self.failIf(None <= IEmpty)
- self.failIf(None == IEmpty)
- self.failUnless(None != IEmpty)
- self.failUnless(None >= IEmpty)
- self.failUnless(None > IEmpty)
-
- def test_comparison_with_same_instance(self):
- from zope.interface import Interface
-
- class IEmpty(Interface):
- pass
-
- self.failIf(IEmpty < IEmpty)
- self.failUnless(IEmpty <= IEmpty)
- self.failUnless(IEmpty == IEmpty)
- self.failIf(IEmpty != IEmpty)
- self.failUnless(IEmpty >= IEmpty)
- self.failIf(IEmpty > IEmpty)
-
- def test_hash(self):
- from zope.interface import Interface
-
- class IEmpty(Interface):
- pass
-
- self.assertEqual(hash(IEmpty),
- hash((IEmpty.__name__, IEmpty.__module__)))
-
-
-if sys.version_info >= (2, 4):
-
- def test_invariant_as_decorator():
- """Invaiants can be deined in line
-
- >>> from zope.interface.exceptions import Invalid
- >>> from zope.interface import Interface
- >>> from zope.interface import Attribute
- >>> from zope.interface import implements
- >>> from zope.interface import invariant
- >>> class IRange(Interface):
- ... min = Attribute("Lower bound")
- ... max = Attribute("Upper bound")
- ...
- ... @invariant
- ... def range_invariant(ob):
- ... if ob.max < ob.min:
- ... raise Invalid('max < min')
-
-
- >>> class Range(object):
- ... implements(IRange)
- ...
- ... def __init__(self, min, max):
- ... self.min, self.max = min, max
-
- >>> from zope.interface.exceptions import Invalid
- >>> IRange.validateInvariants(Range(1,2))
- >>> IRange.validateInvariants(Range(1,1))
- >>> try:
- ... IRange.validateInvariants(Range(2,1))
- ... except Invalid, e:
- ... str(e)
- 'max < min'
-
-
- """
-
-
-def test_description_cache_management():
- """ See https://bugs.launchpad.net/zope.interface/+bug/185974
-
-There was a bug where the cache used by Specification.get() was not
-cleared when the bases were changed.
-
- >>> from zope.interface import Interface
- >>> from zope.interface import Attribute
- >>> class I1(Interface):
- ... a = Attribute('a')
-
- >>> class I2(I1):
- ... pass
-
- >>> class I3(I2):
- ... pass
-
- >>> I3.get('a') is I1.get('a')
- True
- >>> I2.__bases__ = (Interface,)
- >>> I3.get('a') is None
- True
- """
-
-
-def test_suite():
- suite = unittest.makeSuite(InterfaceTests)
- suite.addTest(doctest.DocTestSuite("zope.interface.interface"))
- if sys.version_info >= (2, 4):
- suite.addTest(doctest.DocTestSuite())
- suite.addTest(doctest.DocFileSuite(
- '../README.txt',
- globs={'__name__': '__main__'},
- optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
- ))
- suite.addTest(doctest.DocFileSuite(
- '../README.ru.txt',
- globs={'__name__': '__main__'},
- optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
- ))
- return suite
diff --git a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_odd_declarations.py b/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_odd_declarations.py
deleted file mode 100644
index bce47653..00000000
--- a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_odd_declarations.py
+++ /dev/null
@@ -1,216 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Test interface declarations against ExtensionClass-like classes.
-
-These tests are to make sure we do something sane in the presence of
-classic ExtensionClass classes and instances.
-"""
-import doctest
-import unittest
-
-from zope.interface.tests import odd
-from zope.interface import Interface, implements, classProvides
-from zope.interface import directlyProvides, providedBy, directlyProvidedBy
-from zope.interface import classImplements, classImplementsOnly, implementedBy
-
-class I1(Interface): pass
-class I2(Interface): pass
-class I3(Interface): pass
-class I31(I3): pass
-class I4(Interface): pass
-class I5(Interface): pass
-
-class Odd(object): __metaclass__ = odd.MetaClass
-
-class B(Odd): __implemented__ = I2
-
-
-# TODO: We are going to need more magic to make classProvides work with odd
-# classes. This will work in the next iteration. For now, we'll use
-# a different mechanism.
-
-# from zope.interface import classProvides
-
-class A(Odd):
- pass
-classImplements(A, I1)
-
-class C(A, B):
- pass
-classImplements(C, I31)
-
-
-class Test(unittest.TestCase):
-
- def test_ObjectSpecification(self):
- c = C()
- directlyProvides(c, I4)
- self.assertEqual([i.getName() for i in providedBy(c)],
- ['I4', 'I31', 'I1', 'I2']
- )
- self.assertEqual([i.getName() for i in providedBy(c).flattened()],
- ['I4', 'I31', 'I3', 'I1', 'I2', 'Interface']
- )
- self.assert_(I1 in providedBy(c))
- self.failIf(I3 in providedBy(c))
- self.assert_(providedBy(c).extends(I3))
- self.assert_(providedBy(c).extends(I31))
- self.failIf(providedBy(c).extends(I5))
-
- class COnly(A, B):
- pass
- classImplementsOnly(COnly, I31)
-
- class D(COnly):
- pass
- classImplements(D, I5)
-
- classImplements(D, I5)
-
- c = D()
- directlyProvides(c, I4)
- self.assertEqual([i.getName() for i in providedBy(c)],
- ['I4', 'I5', 'I31'])
- self.assertEqual([i.getName() for i in providedBy(c).flattened()],
- ['I4', 'I5', 'I31', 'I3', 'Interface'])
- self.failIf(I1 in providedBy(c))
- self.failIf(I3 in providedBy(c))
- self.assert_(providedBy(c).extends(I3))
- self.failIf(providedBy(c).extends(I1))
- self.assert_(providedBy(c).extends(I31))
- self.assert_(providedBy(c).extends(I5))
-
- class COnly(A, B): __implemented__ = I31
- class D(COnly):
- pass
- classImplements(D, I5)
-
- classImplements(D, I5)
- c = D()
- directlyProvides(c, I4)
- self.assertEqual([i.getName() for i in providedBy(c)],
- ['I4', 'I5', 'I31'])
- self.assertEqual([i.getName() for i in providedBy(c).flattened()],
- ['I4', 'I5', 'I31', 'I3', 'Interface'])
- self.failIf(I1 in providedBy(c))
- self.failIf(I3 in providedBy(c))
- self.assert_(providedBy(c).extends(I3))
- self.failIf(providedBy(c).extends(I1))
- self.assert_(providedBy(c).extends(I31))
- self.assert_(providedBy(c).extends(I5))
-
- def test_classImplements(self):
- class A(Odd):
- implements(I3)
-
- class B(Odd):
- implements(I4)
-
- class C(A, B):
- pass
- classImplements(C, I1, I2)
- self.assertEqual([i.getName() for i in implementedBy(C)],
- ['I1', 'I2', 'I3', 'I4'])
- classImplements(C, I5)
- self.assertEqual([i.getName() for i in implementedBy(C)],
- ['I1', 'I2', 'I5', 'I3', 'I4'])
-
- def test_classImplementsOnly(self):
- class A(Odd):
- implements(I3)
-
- class B(Odd):
- implements(I4)
-
- class C(A, B):
- pass
- classImplementsOnly(C, I1, I2)
- self.assertEqual([i.__name__ for i in implementedBy(C)],
- ['I1', 'I2'])
-
-
- def test_directlyProvides(self):
- class IA1(Interface): pass
- class IA2(Interface): pass
- class IB(Interface): pass
- class IC(Interface): pass
- class A(Odd):
- pass
- classImplements(A, IA1, IA2)
-
- class B(Odd):
- pass
- classImplements(B, IB)
-
- class C(A, B):
- pass
- classImplements(C, IC)
-
-
- ob = C()
- directlyProvides(ob, I1, I2)
- self.assert_(I1 in providedBy(ob))
- self.assert_(I2 in providedBy(ob))
- self.assert_(IA1 in providedBy(ob))
- self.assert_(IA2 in providedBy(ob))
- self.assert_(IB in providedBy(ob))
- self.assert_(IC in providedBy(ob))
-
- directlyProvides(ob, directlyProvidedBy(ob)-I2)
- self.assert_(I1 in providedBy(ob))
- self.failIf(I2 in providedBy(ob))
- self.failIf(I2 in providedBy(ob))
- directlyProvides(ob, directlyProvidedBy(ob), I2)
- self.assert_(I2 in providedBy(ob))
-
- def test_directlyProvides_fails_for_odd_class(self):
- self.assertRaises(TypeError, directlyProvides, C, I5)
-
- # see above
- def TODO_test_classProvides_fails_for_odd_class(self):
- try:
- class A(Odd):
- classProvides(I1)
- except TypeError:
- pass # Sucess
- self.assert_(False,
- "Shouldn't be able to use directlyProvides on odd class."
- )
-
- def test_implementedBy(self):
- class I2(I1): pass
-
- class C1(Odd):
- pass
- classImplements(C1, I2)
-
- class C2(C1):
- pass
- classImplements(C2, I3)
-
- self.assertEqual([i.getName() for i in implementedBy(C2)],
- ['I3', 'I2'])
-
-
-
-
-def test_suite():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(Test))
- suite.addTest(doctest.DocTestSuite(odd))
- return suite
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_sorting.py b/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_sorting.py
deleted file mode 100644
index af60f88b..00000000
--- a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_sorting.py
+++ /dev/null
@@ -1,55 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Test interface sorting
-"""
-
-from unittest import TestCase, TestSuite, main, makeSuite
-
-from zope.interface import Interface
-
-class I1(Interface): pass
-class I2(I1): pass
-class I3(I1): pass
-class I4(Interface): pass
-class I5(I4): pass
-class I6(I2): pass
-
-
-class Test(TestCase):
-
- def test(self):
- l = [I1, I3, I5, I6, I4, I2]
- l.sort()
- self.assertEqual(l, [I1, I2, I3, I4, I5, I6])
-
- def test_w_None(self):
- l = [I1, None, I3, I5, I6, I4, I2]
- l.sort()
- self.assertEqual(l, [I1, I2, I3, I4, I5, I6, None])
-
- def test_w_equal_names(self):
- # interfaces with equal names but different modules should sort by
- # module name
- from zope.interface.tests.m1 import I1 as m1_I1
- l = [I1, m1_I1]
- l.sort()
- self.assertEqual(l, [m1_I1, I1])
-
-def test_suite():
- return TestSuite((
- makeSuite(Test),
- ))
-
-if __name__=='__main__':
- main(defaultTest='test_suite')
diff --git a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_verify.py b/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_verify.py
deleted file mode 100644
index 1e2282fb..00000000
--- a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/test_verify.py
+++ /dev/null
@@ -1,200 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Interface Verify tests
-"""
-import doctest
-import unittest
-
-from zope.interface import Interface, implements, classImplements, Attribute
-from zope.interface.verify import verifyClass, verifyObject
-from zope.interface.exceptions import DoesNotImplement, BrokenImplementation
-from zope.interface.exceptions import BrokenMethodImplementation
-
-class Test(unittest.TestCase):
-
- def testNotImplemented(self):
-
- class C(object): pass
-
- class I(Interface): pass
-
- self.assertRaises(DoesNotImplement, verifyClass, I, C)
-
- classImplements(C, I)
-
- verifyClass(I, C)
-
- def testMissingAttr(self):
-
- class I(Interface):
- def f(): pass
-
- class C(object):
- implements(I)
-
- self.assertRaises(BrokenImplementation, verifyClass, I, C)
-
- C.f=lambda self: None
-
- verifyClass(I, C)
-
- def testMissingAttr_with_Extended_Interface(self):
-
- class II(Interface):
- def f():
- pass
-
- class I(II):
- pass
-
- class C(object):
- implements(I)
-
- self.assertRaises(BrokenImplementation, verifyClass, I, C)
-
- C.f=lambda self: None
-
- verifyClass(I, C)
-
- def testWrongArgs(self):
-
- class I(Interface):
- def f(a): pass
-
- class C(object):
- def f(self, b): pass
-
- implements(I)
-
- # We no longer require names to match.
- #self.assertRaises(BrokenMethodImplementation, verifyClass, I, C)
-
- C.f=lambda self, a: None
-
- verifyClass(I, C)
-
- C.f=lambda self, **kw: None
-
- self.assertRaises(BrokenMethodImplementation, verifyClass, I, C)
-
- C.f=lambda self, a, *args: None
-
- verifyClass(I, C)
-
- C.f=lambda self, a, *args, **kw: None
-
- verifyClass(I, C)
-
- C.f=lambda self, *args: None
-
- verifyClass(I, C)
-
- def testExtraArgs(self):
-
- class I(Interface):
- def f(a): pass
-
- class C(object):
- def f(self, a, b): pass
-
- implements(I)
-
- self.assertRaises(BrokenMethodImplementation, verifyClass, I, C)
-
- C.f=lambda self, a: None
-
- verifyClass(I, C)
-
- C.f=lambda self, a, b=None: None
-
- verifyClass(I, C)
-
- def testNoVar(self):
-
- class I(Interface):
- def f(a, *args): pass
-
- class C(object):
- def f(self, a): pass
-
- implements(I)
-
- self.assertRaises(BrokenMethodImplementation, verifyClass, I, C)
-
- C.f=lambda self, a, *foo: None
-
- verifyClass(I, C)
-
- def testNoKW(self):
-
- class I(Interface):
- def f(a, **args): pass
-
- class C(object):
- def f(self, a): pass
-
- implements(I)
-
- self.assertRaises(BrokenMethodImplementation, verifyClass, I, C)
-
- C.f=lambda self, a, **foo: None
-
- verifyClass(I, C)
-
- def testModule(self):
-
- from zope.interface.tests.ifoo import IFoo
- from zope.interface.tests import dummy
-
- verifyObject(IFoo, dummy)
-
- def testMethodForAttr(self):
-
- class IFoo(Interface):
- foo = Attribute("The foo Attribute")
-
-
- class Foo:
- implements(IFoo)
-
- def foo(self):
- pass
-
- verifyClass(IFoo, Foo)
-
- def testNonMethodForMethod(self):
-
- class IBar(Interface):
- def foo():
- pass
-
- class Bar:
- implements(IBar)
-
- foo = 1
-
- self.assertRaises(BrokenMethodImplementation, verifyClass, IBar, Bar)
-
-
-def test_suite():
- loader=unittest.TestLoader()
- return unittest.TestSuite((
- doctest.DocFileSuite(
- '../verify.txt',
- optionflags=doctest.NORMALIZE_WHITESPACE),
- loader.loadTestsFromTestCase(Test),
- ))
-
-if __name__=='__main__':
- unittest.TextTestRunner().run(test_suite())
diff --git a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/unitfixtures.py b/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/unitfixtures.py
deleted file mode 100644
index c47eaf0d..00000000
--- a/lib/python2.7/site-packages/zope.interface-3.6.4-py2.7-linux-x86_64.egg/zope/interface/tests/unitfixtures.py
+++ /dev/null
@@ -1,140 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Unit Test Fixtures
-"""
-from zope.interface import Interface, invariant
-from zope.interface.interface import Attribute
-from zope.interface.exceptions import Invalid
-
-class mytest(Interface):
- pass
-
-class C(object):
- def m1(self, a, b):
- "return 1"
- return 1
-
- def m2(self, a, b):
- "return 2"
- return 2
-
-# testInstancesOfClassImplements
-
-# YAGNI IC=Interface.impliedInterface(C)
-class IC(Interface):
- def m1(a, b):
- "return 1"
-
- def m2(a, b):
- "return 2"
-
-
-
-C.__implemented__=IC
-
-class I1(Interface):
- def ma():
- "blah"
-
-class I2(I1): pass
-
-class I3(Interface): pass
-
-class I4(Interface): pass
-
-class A(I1.deferred()):
- __implemented__=I1
-
-class B(object):
- __implemented__=I2, I3
-
-class D(A, B): pass
-
-class E(A, B):
- __implemented__ = A.__implemented__, C.__implemented__
-
-
-class FooInterface(Interface):
- """ This is an Abstract Base Class """
-
- foobar = Attribute("fuzzed over beyond all recognition")
-
- def aMethod(foo, bar, bingo):
- """ This is aMethod """
-
- def anotherMethod(foo=6, bar="where you get sloshed", bingo=(1,3,)):
- """ This is anotherMethod """
-
- def wammy(zip, *argues):
- """ yadda yadda """
-
- def useless(**keywords):
- """ useless code is fun! """
-
-class Foo(object):
- """ A concrete class """
-
- __implemented__ = FooInterface,
-
- foobar = "yeah"
-
- def aMethod(self, foo, bar, bingo):
- """ This is aMethod """
- return "barf!"
-
- def anotherMethod(self, foo=6, bar="where you get sloshed", bingo=(1,3,)):
- """ This is anotherMethod """
- return "barf!"
-
- def wammy(self, zip, *argues):
- """ yadda yadda """
- return "barf!"
-
- def useless(self, **keywords):
- """ useless code is fun! """
- return "barf!"
-
-foo_instance = Foo()
-
-class Blah(object):
- pass
-
-new = Interface.__class__
-FunInterface = new('FunInterface')
-BarInterface = new('BarInterface', [FunInterface])
-BobInterface = new('BobInterface')
-BazInterface = new('BazInterface', [BobInterface, BarInterface])
-
-# fixtures for invariant tests
-def ifFooThenBar(obj):
- if getattr(obj, 'foo', None) and not getattr(obj, 'bar', None):
- raise Invalid('If Foo, then Bar!')
-class IInvariant(Interface):
- foo = Attribute('foo')
- bar = Attribute('bar; must eval to Boolean True if foo does')
- invariant(ifFooThenBar)
-def BarGreaterThanFoo(obj):
- foo = getattr(obj, 'foo', None)
- bar = getattr(obj, 'bar', None)
- if foo is not None and isinstance(foo, type(bar)):
- # type checking should be handled elsewhere (like, say,
- # schema); these invariants should be intra-interface
- # constraints. This is a hacky way to do it, maybe, but you
- # get the idea
- if not bar > foo:
- raise Invalid('Please, Boo MUST be greater than Foo!')
-class ISubInvariant(IInvariant):
- invariant(BarGreaterThanFoo)
-class InvariantC(object):
- pass