diff options
| author | YDBot <[email protected]> | 2025-09-29 00:52:20 +0000 |
|---|---|---|
| committer | YDBot <[email protected]> | 2025-09-29 00:52:20 +0000 |
| commit | 004b5afa98d6c9c2c8c77e519b378c8e5cd13aee (patch) | |
| tree | bcbdba698e99050625b40810d7b244d1546c03f8 /contrib/python | |
| parent | f737e3e3baee5bdb3c574846d8ec712b0d49853a (diff) | |
| parent | 2fec1df526df92f0b865d8708d5a67fd82e6a6ba (diff) | |
Sync branches 250929-0050
Diffstat (limited to 'contrib/python')
7 files changed, 156 insertions, 159 deletions
diff --git a/contrib/python/zope.interface/py3/.dist-info/METADATA b/contrib/python/zope.interface/py3/.dist-info/METADATA index 279d71d4f08..e037cb7ebfe 100644 --- a/contrib/python/zope.interface/py3/.dist-info/METADATA +++ b/contrib/python/zope.interface/py3/.dist-info/METADATA @@ -1,11 +1,11 @@ -Metadata-Version: 2.1 +Metadata-Version: 2.4 Name: zope.interface -Version: 7.2 +Version: 8.0 Summary: Interfaces for Python Home-page: https://github.com/zopefoundation/zope.interface Author: Zope Foundation and Contributors Author-email: [email protected] -License: ZPL 2.1 +License: ZPL-2.1 Keywords: interface,components,plugins Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers @@ -13,7 +13,6 @@ Classifier: License :: OSI Approved :: Zope Public License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: 3.11 @@ -23,22 +22,35 @@ Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Framework :: Zope :: 3 Classifier: Topic :: Software Development :: Libraries :: Python Modules -Requires-Python: >=3.8 +Requires-Python: >=3.9 Description-Content-Type: text/x-rst License-File: LICENSE.txt Requires-Dist: setuptools Provides-Extra: docs -Requires-Dist: Sphinx ; extra == 'docs' -Requires-Dist: repoze.sphinx.autointerface ; extra == 'docs' -Requires-Dist: furo ; extra == 'docs' +Requires-Dist: Sphinx; extra == "docs" +Requires-Dist: repoze.sphinx.autointerface; extra == "docs" +Requires-Dist: furo; extra == "docs" Provides-Extra: test -Requires-Dist: coverage[toml] ; extra == 'test' -Requires-Dist: zope.event ; extra == 'test' -Requires-Dist: zope.testing ; extra == 'test' +Requires-Dist: coverage[toml]; extra == "test" +Requires-Dist: zope.event; extra == "test" +Requires-Dist: zope.testing; extra == "test" Provides-Extra: testing -Requires-Dist: coverage[toml] ; extra == 'testing' -Requires-Dist: zope.event ; extra == 'testing' -Requires-Dist: zope.testing ; extra == 'testing' +Requires-Dist: coverage[toml]; extra == "testing" +Requires-Dist: zope.event; extra == "testing" +Requires-Dist: zope.testing; extra == "testing" +Dynamic: author +Dynamic: author-email +Dynamic: classifier +Dynamic: description +Dynamic: description-content-type +Dynamic: home-page +Dynamic: keywords +Dynamic: license +Dynamic: license-file +Dynamic: provides-extra +Dynamic: requires-dist +Dynamic: requires-python +Dynamic: summary ==================== ``zope.interface`` @@ -76,6 +88,17 @@ For detailed documentation, please see https://zopeinterface.readthedocs.io/en/l Changes ========= +8.0 (2025-09-12) +================ + +- Replace ``pkg_resources`` namespace with PEP 420 native namespace. + +- Drop support for Python 3.8. + +- Allow using newer ``setuptools`` version. + (`#333 <https://github.com/zopefoundation/zope.interface/issues/333>`_) + + 7.2 (2024-11-28) ================ diff --git a/contrib/python/zope.interface/py3/patches/01-fix-tests.patch b/contrib/python/zope.interface/py3/patches/01-fix-tests.patch index 8b9210b158f..caf8f31514f 100644 --- a/contrib/python/zope.interface/py3/patches/01-fix-tests.patch +++ b/contrib/python/zope.interface/py3/patches/01-fix-tests.patch @@ -109,8 +109,8 @@ - 'zope.interface.tests.test_declarations.foo') + '__tests__.tests.test_declarations.foo') @@ -697,1 +697,1 @@ class Test_implementedByFallback(unittest.TestCase): -- 'zope.interface.tests.test_declarations.Foo') -+ '__tests__.tests.test_declarations.Foo') +- 'zope.interface.tests.test_declarations.FooImplementedNone') ++ '__tests__.tests.test_declarations.FooImplementedNone') @@ -1034,1 +1034,1 @@ class Test_classImplements(_ImplementsTestMixin, unittest.TestCase): - from zope.interface.tests.test_ro import C3Setting + from __tests__.tests.test_ro import C3Setting @@ -123,32 +123,9 @@ @@ -1379,1 +1379,1 @@ class TestProvidesClassRepr(unittest.TestCase): - "sys.modules['zope.interface.tests.dummy'], " + "sys.modules['__tests__.tests.dummy'], " -@@ -1387 +1387 @@ class TestProvidesClassRepr(unittest.TestCase): -- from zope.interface.tests import dummy -+ from . import dummy -@@ -1399,1 +1399,1 @@ class TestProvidesClassRepr(unittest.TestCase): -- from zope.interface.tests import dummy -+ from __tests__.tests import dummy -@@ -1425 +1425 @@ class TestProvidesClassRepr(unittest.TestCase): -+ "directlyProvides(sys.modules['__tests__.tests.dummy'], IFoo)" -- "directlyProvides(sys.modules['zope.interface.tests.dummy'], IFoo)" -@@ -1450,1 +1450,1 @@ class TestProvidesClassRepr(unittest.TestCase): -- "sys.modules['zope.interface.tests.dummy'], " -+ "sys.modules['__tests__.tests.dummy'], " -@@ -1436,2 +1436,2 @@ class TestProvidesClassRepr(unittest.TestCase): -- "directlyProvides(('zope.interface.tests.dummy', " -- "'zope.interface.tests.test_declarations'), " -+ "directlyProvides(('__tests__.tests.dummy', " -+ "'__tests__.tests.test_declarations'), " @@ -2074,1 +2074,1 @@ class Test_moduleProvides(unittest.TestCase): - globs = {'__name__': 'zope.interface.tests.foo', + globs = {'__name__': '__tests__.tests.tests.foo', -@@ -2103,1 +2103,1 @@ class Test_moduleProvides(unittest.TestCase): -- globs = {'__name__': 'zope.interface.tests.foo', -+ globs = {'__name__': '__tests__.tests.tests.foo', -@@ -2116,1 +2116,1 @@ class Test_moduleProvides(unittest.TestCase): -- globs = {'__name__': 'zope.interface.tests.foo', -+ globs = {'__name__': '__tests__.tests.tests.foo', --- contrib/python/zope.interface/py3/zope/interface/tests/test_exceptions.py (index) +++ contrib/python/zope.interface/py3/zope/interface/tests/test_exceptions.py (working tree) @@ -36,1 +36,1 @@ class DoesNotImplementTests(unittest.TestCase): @@ -210,7 +187,7 @@ + from . import dummy --- contrib/python/zope.interface/py3/zope/interface/tests/test_ro.py (index) +++ contrib/python/zope.interface/py3/zope/interface/tests/test_ro.py (working tree) -@@ -221,218 +221,0 @@ class C3Setting: +@@ -224,218 +223,0 @@ class C3Setting: -class Test_c3_ro(Test_ro): - - def setUp(self): @@ -288,17 +265,17 @@ - - expected = """\ -Object <InterfaceClass {name}> has different legacy and C3 MROs: -- Legacy RO (len=7) C3 RO (len=7; inconsistent=no) -- ================================================================== -- zope.interface.tests.test_ro.A zope.interface.tests.test_ro.A -- zope.interface.tests.test_ro.B zope.interface.tests.test_ro.B -- - zope.interface.tests.test_ro.E -- zope.interface.tests.test_ro.C zope.interface.tests.test_ro.C -- zope.interface.tests.test_ro.D zope.interface.tests.test_ro.D -- + zope.interface.tests.test_ro.E -- zope.interface.tests.test_ro.F zope.interface.tests.test_ro.F -- zope.interface.Interface zope.interface.Interface""".format( -- name="zope.interface.tests.test_ro.A" +- Legacy RO (len=7) C3 RO (len=7; inconsistent=no) +- ======================================================== +- interface.tests.test_ro.A interface.tests.test_ro.A +- interface.tests.test_ro.B interface.tests.test_ro.B +- - interface.tests.test_ro.E +- interface.tests.test_ro.C interface.tests.test_ro.C +- interface.tests.test_ro.D interface.tests.test_ro.D +- + interface.tests.test_ro.E +- interface.tests.test_ro.F interface.tests.test_ro.F +- zope.interface.Interface zope.interface.Interface""".format( +- name="interface.tests.test_ro.A" - ) - - self.assertEqual( @@ -429,3 +406,57 @@ - self.assertEqual(iro, legacy_iro) - - +--- contrib/python/zope.interface/py3/zope/interface/tests/test_declarations.py (index) ++++ contrib/python/zope.interface/py3/zope/interface/tests/test_declarations.py (working tree) +@@ -672 +672 @@ class Test_implementedByFallback(unittest.TestCase): +- from zope.interface.tests.test_declarations import FooNoCall ++ from __tests__.tests.test_declarations import FooNoCall +@@ -688 +688 @@ class Test_implementedByFallback(unittest.TestCase): +- from zope.interface.tests.test_declarations import FooImplementedNone ++ from __tests__.tests.test_declarations import FooImplementedNone +@@ -1156 +1156 @@ class Test_implementer(Test_classImplements): +- from zope.interface.tests.test_declarations import Foo ++ from __tests__.tests.test_declarations import Foo +@@ -1351 +1351 @@ class TestProvidesClassRepr(unittest.TestCase): +- from zope.interface.tests import dummy ++ from __tests__.tests import dummy +@@ -1356 +1356 @@ class TestProvidesClassRepr(unittest.TestCase): +- "sys.modules['zope.interface.tests.dummy'], " ++ "sys.modules['__tests__.tests.dummy'], " +@@ -1375,2 +1375,2 @@ class TestProvidesClassRepr(unittest.TestCase): +- from zope.interface.tests import dummy +- from zope.interface.tests.test_declarations import IFoo ++ from __tests__.tests import dummy ++ from __tests__.tests.test_declarations import IFoo +@@ -1389 +1389 @@ class TestProvidesClassRepr(unittest.TestCase): +- "directlyProvides(sys.modules['zope.interface.tests.dummy'], IFoo)" ++ "directlyProvides(sys.modules['__tests__.tests.dummy'], IFoo)" +@@ -1412,2 +1412,2 @@ class TestProvidesClassRepr(unittest.TestCase): +- "directlyProvides(('zope.interface.tests.dummy', " +- "'interface.tests.test_declarations'), " ++ "directlyProvides(('__tests__.tests.dummy', " ++ "'__tests__.tests.test_declarations'), " +@@ -2023 +2023 @@ class Test_moduleProvides(unittest.TestCase): +- globs = {'__name__': 'zope.interface.tests.foo', ++ globs = {'__name__': '__tests__.tests.foo', +@@ -2037 +2037 @@ class Test_moduleProvides(unittest.TestCase): +- globs = {'__name__': 'zope.interface.tests.foo', ++ globs = {'__name__': '__tests__.tests.foo', +@@ -2050 +2050 @@ class Test_moduleProvides(unittest.TestCase): +- globs = {'__name__': 'zope.interface.tests.foo', ++ globs = {'__name__': '__tests__.tests.foo', +--- contrib/python/zope.interface/py3/zope/interface/tests/test_exceptions.py (index) ++++ contrib/python/zope.interface/py3/zope/interface/tests/test_exceptions.py (working tree) +@@ -26 +26 @@ def _makeIface(): +- from zope.interface.tests.test_exceptions import IDummy ++ from __tests__.tests.test_exceptions import IDummy +--- contrib/python/zope.interface/py3/zope/interface/tests/test_interface.py (index) ++++ contrib/python/zope.interface/py3/zope/interface/tests/test_interface.py (working tree) +@@ -1177 +1177 @@ class InterfaceClassTests(unittest.TestCase): +- from zope.interface.tests.test_interface import HashMe as iface ++ from __tests__.tests.test_interface import HashMe as iface +--- contrib/python/zope.interface/py3/zope/interface/tests/test_sorting.py (index) ++++ contrib/python/zope.interface/py3/zope/interface/tests/test_sorting.py (working tree) +@@ -64 +64 @@ class Test(unittest.TestCase): +- from zope.interface.tests.test_sorting import I1 ++ from __tests__.tests.test_sorting import I1 diff --git a/contrib/python/zope.interface/py3/ya.make b/contrib/python/zope.interface/py3/ya.make index fd9015ba6bc..83ef8a66f88 100644 --- a/contrib/python/zope.interface/py3/ya.make +++ b/contrib/python/zope.interface/py3/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(7.2) +VERSION(8.0) LICENSE(ZPL-2.1) diff --git a/contrib/python/zope.interface/py3/zope/interface/tests/test_declarations.py b/contrib/python/zope.interface/py3/zope/interface/tests/test_declarations.py index 64fc0e0696b..c684d7c61e2 100644 --- a/contrib/python/zope.interface/py3/zope/interface/tests/test_declarations.py +++ b/contrib/python/zope.interface/py3/zope/interface/tests/test_declarations.py @@ -15,6 +15,7 @@ """ import unittest +from zope.interface.interface import InterfaceClass from __tests__.tests import MissingSomeAttrs from __tests__.tests import OptimizationTestMixin from __tests__.tests import SubclassableMixin @@ -25,6 +26,24 @@ from __tests__.tests.test_interface import \ # pylint:disable=inherit-non-class,too-many-lines,protected-access # pylint:disable=blacklisted-name,attribute-defined-outside-init +IFoo = InterfaceClass('IFoo') + + +class Foo: + pass + + +class FooImplementedNone: + __implemented__ = None + + +class FooNoCall: + __implemented__ = None + + def __call__(self): + raise NotImplementedError() + + class _Py3ClassAdvice: def _run_generated_code( @@ -152,7 +171,6 @@ class DeclarationTests(EmptyDeclarationTests): self.assertEqual(list(decl.__bases__), []) def test_ctor_w_interface_in_bases(self): - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass('IFoo') decl = self._makeOne(IFoo) self.assertEqual(list(decl.__bases__), [IFoo]) @@ -173,39 +191,33 @@ class DeclarationTests(EmptyDeclarationTests): self.assertNotIn(decl, decl) def test___contains__w_unrelated_iface(self): - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass('IFoo') decl = self._makeOne() self.assertNotIn(IFoo, decl) def test___contains__w_base_interface(self): - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass('IFoo') decl = self._makeOne(IFoo) self.assertIn(IFoo, decl) def test___iter___single_base(self): - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass('IFoo') decl = self._makeOne(IFoo) self.assertEqual(list(decl), [IFoo]) def test___iter___multiple_bases(self): - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass('IFoo') IBar = InterfaceClass('IBar') decl = self._makeOne(IFoo, IBar) self.assertEqual(list(decl), [IFoo, IBar]) def test___iter___inheritance(self): - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass('IFoo') IBar = InterfaceClass('IBar', (IFoo,)) decl = self._makeOne(IBar) self.assertEqual(list(decl), [IBar]) # IBar.interfaces() omits bases def test___iter___w_nested_sequence_overlap(self): - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass('IFoo') IBar = InterfaceClass('IBar') decl = self._makeOne(IBar, (IFoo, IBar)) @@ -213,14 +225,12 @@ class DeclarationTests(EmptyDeclarationTests): def test_flattened_single_base(self): from zope.interface.interface import Interface - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass('IFoo') decl = self._makeOne(IFoo) self.assertEqual(list(decl.flattened()), [IFoo, Interface]) def test_flattened_multiple_bases(self): from zope.interface.interface import Interface - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass('IFoo') IBar = InterfaceClass('IBar') decl = self._makeOne(IFoo, IBar) @@ -228,7 +238,6 @@ class DeclarationTests(EmptyDeclarationTests): def test_flattened_inheritance(self): from zope.interface.interface import Interface - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass('IFoo') IBar = InterfaceClass('IBar', (IFoo,)) decl = self._makeOne(IBar) @@ -236,7 +245,6 @@ class DeclarationTests(EmptyDeclarationTests): def test_flattened_w_nested_sequence_overlap(self): from zope.interface.interface import Interface - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass('IFoo') IBar = InterfaceClass('IBar') # This is the same as calling ``Declaration(IBar, IFoo, IBar)`` @@ -248,7 +256,6 @@ class DeclarationTests(EmptyDeclarationTests): self.assertEqual(list(decl.flattened()), [IBar, IFoo, Interface]) def test___sub___unrelated_interface(self): - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass('IFoo') IBar = InterfaceClass('IBar') before = self._makeOne(IFoo) @@ -257,14 +264,12 @@ class DeclarationTests(EmptyDeclarationTests): self.assertEqual(list(after), [IFoo]) def test___sub___related_interface(self): - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass('IFoo') before = self._makeOne(IFoo) after = before - IFoo self.assertEqual(list(after), []) def test___sub___related_interface_by_inheritance(self): - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass('IFoo') IBar = InterfaceClass('IBar', (IFoo,)) before = self._makeOne(IBar) @@ -272,7 +277,6 @@ class DeclarationTests(EmptyDeclarationTests): self.assertEqual(list(after), []) def test___add___unrelated_interface(self): - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass('IFoo') IBar = InterfaceClass('IBar') before = self._makeOne(IFoo) @@ -281,7 +285,6 @@ class DeclarationTests(EmptyDeclarationTests): self.assertEqual(list(after), [IFoo, IBar]) def test___add___related_interface(self): - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass('IFoo') IBar = InterfaceClass('IBar') IBaz = InterfaceClass('IBaz') @@ -298,7 +301,6 @@ class DeclarationTests(EmptyDeclarationTests): # the other way). from zope.interface import Interface from zope.interface import ro - from zope.interface.interface import InterfaceClass from __tests__.tests.test_ro import C3Setting IBase = InterfaceClass('IBase') @@ -445,7 +447,6 @@ class TestImplements(NameAndModuleComparisonTestsMixin, def test_sort(self): from zope.interface.declarations import implementedBy - from zope.interface.interface import InterfaceClass class A: pass @@ -597,7 +598,6 @@ class Test_implementedByFallback(unittest.TestCase): self.assertIs(self._callFUT(foo), impl) def test_dictless_w_existing_not_Implements(self): - from zope.interface.interface import InterfaceClass class Foo: __slots__ = ('__implemented__',) @@ -669,14 +669,9 @@ class Test_implementedByFallback(unittest.TestCase): def test_w_None_no_bases_w_factory(self): from zope.interface.declarations import objectSpecificationDescriptor + from __tests__.tests.test_declarations import FooNoCall - class Foo: - __implemented__ = None - - def __call__(self): - raise NotImplementedError() - - foo = Foo() + foo = FooNoCall() foo.__name__ = 'foo' spec = self._callFUT(foo) self.assertEqual(spec.__name__, @@ -690,23 +685,22 @@ class Test_implementedByFallback(unittest.TestCase): def test_w_None_no_bases_w_class(self): from zope.interface.declarations import ClassProvides + from __tests__.tests.test_declarations import FooImplementedNone - class Foo: - __implemented__ = None - - spec = self._callFUT(Foo) - self.assertEqual(spec.__name__, - '__tests__.tests.test_declarations.Foo') - self.assertIs(spec.inherit, Foo) - self.assertIs(Foo.__implemented__, spec) + spec = self._callFUT(FooImplementedNone) + self.assertEqual( + spec.__name__, + '__tests__.tests.test_declarations.FooImplementedNone') + self.assertIs(spec.inherit, FooImplementedNone) + self.assertIs(FooImplementedNone.__implemented__, spec) self.assertIsInstance( - Foo.__providedBy__, ClassProvides + FooImplementedNone.__providedBy__, ClassProvides ) # pylint:disable=no-member self.assertIsInstance( - Foo.__provides__, ClassProvides + FooImplementedNone.__provides__, ClassProvides ) # pylint:disable=no-member self.assertEqual( - Foo.__provides__, Foo.__providedBy__ + FooImplementedNone.__provides__, FooImplementedNone.__providedBy__ ) # pylint:disable=no-member def test_w_existing_Implements(self): @@ -913,7 +907,6 @@ class _ImplementsTestMixin: spec_name=__name__ + '.Foo', inherit="not given"): from zope.interface.declarations import ClassProvides - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass('IFoo') returned = self._callFUT(Foo, IFoo) @@ -953,7 +946,6 @@ class Test_classImplementsOnly(_ImplementsTestMixin, unittest.TestCase): def test_w_existing_Implements(self): from zope.interface.declarations import Implements - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass('IFoo') IBar = InterfaceClass('IBar') impl = Implements(IFoo) @@ -971,7 +963,6 @@ class Test_classImplementsOnly(_ImplementsTestMixin, unittest.TestCase): def test_class(self): from zope.interface.declarations import Implements - from zope.interface.interface import InterfaceClass IBar = InterfaceClass('IBar') old_spec = Implements(IBar) @@ -1053,7 +1044,6 @@ class Test_classImplements(_ImplementsTestMixin, unittest.TestCase): def test_w_existing_Implements(self): from zope.interface.declarations import Implements - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass('IFoo') IBar = InterfaceClass('IBar') impl = Implements(IFoo) @@ -1072,7 +1062,6 @@ class Test_classImplements(_ImplementsTestMixin, unittest.TestCase): def test_w_existing_Implements_w_bases(self): from zope.interface.declarations import Implements - from zope.interface.interface import InterfaceClass IRoot = InterfaceClass('IRoot') ISecondRoot = InterfaceClass('ISecondRoot') IExtendsRoot = InterfaceClass('IExtendsRoot', (IRoot,)) @@ -1129,7 +1118,6 @@ class Test__implements_advice(unittest.TestCase): def test_no_existing_implements(self): from zope.interface.declarations import Implements from zope.interface.declarations import classImplements - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass('IFoo') class Foo: @@ -1159,18 +1147,13 @@ class Test_implementer(Test_classImplements): return decorator(cls) def test_nonclass_cannot_assign_attr(self): - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass('IFoo') decorator = self._makeOne(IFoo) self.assertRaises(TypeError, decorator, object()) def test_nonclass_can_assign_attr(self): - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass('IFoo') - - class Foo: - pass - + from __tests__.tests.test_declarations import Foo foo = Foo() decorator = self._makeOne(IFoo) returned = decorator(foo) @@ -1190,7 +1173,6 @@ class Test_implementer(Test_classImplements): # https://github.com/zopefoundation/zope.interface/issues/216 import gc - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass('IFoo') begin_count = len(gc.get_objects()) @@ -1227,7 +1209,6 @@ class Test_implementer_only(Test_classImplementsOnly): return decorator(cls) def test_function(self): - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass('IFoo') decorator = self._makeOne(IFoo) @@ -1237,7 +1218,6 @@ class Test_implementer_only(Test_classImplementsOnly): self.assertRaises(ValueError, decorator, _function) def test_method(self): - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass('IFoo') decorator = self._makeOne(IFoo) @@ -1258,7 +1238,6 @@ class ProvidesClassTests(unittest.TestCase): return self._getTargetClass()(*args, **kw) def test_simple_class_one_interface(self): - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") class Foo: @@ -1269,7 +1248,6 @@ class ProvidesClassTests(unittest.TestCase): def test___reduce__(self): from zope.interface.declarations import Provides # the function - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") class Foo: @@ -1281,7 +1259,6 @@ class ProvidesClassTests(unittest.TestCase): self.assertEqual(args, (Foo, IFoo)) def test___get___class(self): - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") class Foo: @@ -1292,7 +1269,6 @@ class ProvidesClassTests(unittest.TestCase): self.assertIs(Foo.__provides__, spec) def test___get___instance(self): - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") class Foo: @@ -1356,7 +1332,6 @@ class TestProvidesClassRepr(unittest.TestCase): return self._getTargetClass()(*args, **kw) def test__repr__(self): - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") assert IFoo.__name__ == 'IFoo' assert IFoo.__module__ == __name__ @@ -1373,7 +1348,7 @@ class TestProvidesClassRepr(unittest.TestCase): def test__repr__module_provides_typical_use(self): # as created through a ``moduleProvides()`` statement # in a module body - from . import dummy + from __tests__.tests import dummy provides = dummy.__provides__ # pylint:disable=no-member self.assertEqual( repr(provides), @@ -1397,10 +1372,9 @@ class TestProvidesClassRepr(unittest.TestCase): from zope.interface.declarations import alsoProvides from zope.interface.declarations import directlyProvides - from zope.interface.interface import InterfaceClass from __tests__.tests import dummy + from __tests__.tests.test_declarations import IFoo - IFoo = InterfaceClass('IFoo') IBar = InterfaceClass('IBar') orig_provides = dummy.__provides__ # pylint:disable=no-member @@ -1442,7 +1416,6 @@ class TestProvidesClassRepr(unittest.TestCase): def test__repr__module_provides_cached_shared(self): from zope.interface.declarations import ModuleType - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") inst = self._makeOne(ModuleType, IFoo) @@ -1454,7 +1427,6 @@ class TestProvidesClassRepr(unittest.TestCase): ) def test__repr__duplicate_names(self): - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo", __module__='mod1') IFoo2 = InterfaceClass("IFoo", __module__='mod2') IBaz = InterfaceClass("IBaz") @@ -1513,7 +1485,6 @@ class TestProvidesClassRepr(unittest.TestCase): def test__repr__providedBy_from_class(self): from zope.interface.declarations import implementer from zope.interface.declarations import providedBy - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") @implementer(IFoo) @@ -1530,7 +1501,6 @@ class TestProvidesClassRepr(unittest.TestCase): from zope.interface.declarations import alsoProvides from zope.interface.declarations import implementer from zope.interface.declarations import providedBy - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") IBar = InterfaceClass("IBar") @@ -1556,7 +1526,6 @@ class Test_Provides(unittest.TestCase): def test_no_cached_spec(self): from zope.interface import declarations - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") cache = {} @@ -1570,7 +1539,6 @@ class Test_Provides(unittest.TestCase): def test_w_cached_spec(self): from zope.interface import declarations - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") prior = object() @@ -1591,7 +1559,6 @@ class Test_directlyProvides(unittest.TestCase): def test_w_normal_object(self): from zope.interface.declarations import ProvidesClass - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") class Foo: @@ -1608,7 +1575,6 @@ class Test_directlyProvides(unittest.TestCase): def test_w_class(self): from zope.interface.declarations import ClassProvides - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") class Foo: @@ -1624,7 +1590,6 @@ class Test_directlyProvides(unittest.TestCase): def test_w_classless_object(self): from zope.interface.declarations import ProvidesClass - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") the_dict = {} @@ -1652,7 +1617,6 @@ class Test_alsoProvides(unittest.TestCase): def test_wo_existing_provides(self): from zope.interface.declarations import ProvidesClass - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") class Foo: @@ -1670,7 +1634,6 @@ class Test_alsoProvides(unittest.TestCase): def test_w_existing_provides(self): from zope.interface.declarations import ProvidesClass from zope.interface.declarations import directlyProvides - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") IBar = InterfaceClass("IBar") @@ -1695,7 +1658,6 @@ class Test_noLongerProvides(unittest.TestCase): return noLongerProvides(*args, **kw) def test_wo_existing_provides(self): - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") class Foo: @@ -1709,7 +1671,6 @@ class Test_noLongerProvides(unittest.TestCase): def test_w_existing_provides_hit(self): from zope.interface.declarations import directlyProvides - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") class Foo: @@ -1724,7 +1685,6 @@ class Test_noLongerProvides(unittest.TestCase): def test_w_existing_provides_miss(self): from zope.interface.declarations import directlyProvides - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") IBar = InterfaceClass("IBar") @@ -1740,7 +1700,6 @@ class Test_noLongerProvides(unittest.TestCase): def test_w_iface_implemented_by_class(self): from zope.interface.declarations import implementer - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") @implementer(IFoo) @@ -1770,7 +1729,6 @@ class ClassProvidesBaseFallbackTests(unittest.TestCase): return Derived(klass, implements) def test_w_same_class_via_class(self): - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") class Foo: @@ -1780,7 +1738,6 @@ class ClassProvidesBaseFallbackTests(unittest.TestCase): self.assertIs(Foo.__provides__, cpbp) def test_w_same_class_via_instance(self): - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") class Foo: @@ -1791,7 +1748,6 @@ class ClassProvidesBaseFallbackTests(unittest.TestCase): self.assertIs(foo.__provides__, IFoo) def test_w_different_class(self): - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") class Foo: @@ -1834,7 +1790,6 @@ class ClassProvidesTests(unittest.TestCase): def test_w_simple_metaclass(self): from zope.interface.declarations import implementer - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") IBar = InterfaceClass("IBar") @@ -1848,7 +1803,6 @@ class ClassProvidesTests(unittest.TestCase): def test___reduce__(self): from zope.interface.declarations import implementer - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") IBar = InterfaceClass("IBar") @@ -1935,7 +1889,6 @@ class TestClassProvidesRepr(unittest.TestCase): ) def test__repr__duplicate_names(self): - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo", __module__='mod1') IFoo2 = InterfaceClass("IFoo", __module__='mod2') IBaz = InterfaceClass("IBaz") @@ -1949,7 +1902,6 @@ class TestClassProvidesRepr(unittest.TestCase): def test__repr__implementedBy(self): from zope.interface.declarations import implementedBy from zope.interface.declarations import implementer - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") @implementer(IFoo) @@ -2002,7 +1954,6 @@ class Test_directlyProvidedBy(unittest.TestCase): def test_w_declarations_in_class_but_not_instance(self): from zope.interface.declarations import implementer - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") @implementer(IFoo) @@ -2014,7 +1965,6 @@ class Test_directlyProvidedBy(unittest.TestCase): def test_w_declarations_in_instance_but_not_class(self): from zope.interface.declarations import directlyProvides - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") class Foo: @@ -2027,7 +1977,6 @@ class Test_directlyProvidedBy(unittest.TestCase): def test_w_declarations_in_instance_and_class(self): from zope.interface.declarations import directlyProvides from zope.interface.declarations import implementer - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") IBar = InterfaceClass("IBar") @@ -2051,7 +2000,6 @@ class Test_provider(unittest.TestCase): def test_w_class(self): from zope.interface.declarations import ClassProvides - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") @self._makeOne(IFoo) @@ -2071,9 +2019,8 @@ class Test_moduleProvides(unittest.TestCase): def test_called_from_function(self): from zope.interface.declarations import moduleProvides - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") - globs = {'__name__': '__tests__.tests.tests.foo', + globs = {'__name__': '__tests__.tests.foo', 'moduleProvides': moduleProvides, 'IFoo': IFoo} locs = {} CODE = "\n".join([ @@ -2086,9 +2033,8 @@ class Test_moduleProvides(unittest.TestCase): def test_called_from_class(self): from zope.interface.declarations import moduleProvides - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") - globs = {'__name__': 'zope.interface.tests.foo', + globs = {'__name__': '__tests__.tests.foo', 'moduleProvides': moduleProvides, 'IFoo': IFoo} locs = {} CODE = "\n".join([ @@ -2100,9 +2046,8 @@ class Test_moduleProvides(unittest.TestCase): def test_called_once_from_module_scope(self): from zope.interface.declarations import moduleProvides - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") - globs = {'__name__': '__tests__.tests.tests.foo', + globs = {'__name__': '__tests__.tests.foo', 'moduleProvides': moduleProvides, 'IFoo': IFoo} CODE = "\n".join([ 'moduleProvides(IFoo)', @@ -2113,7 +2058,6 @@ class Test_moduleProvides(unittest.TestCase): def test_called_twice_from_module_scope(self): from zope.interface.declarations import moduleProvides - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") globs = {'__name__': '__tests__.tests.tests.foo', 'moduleProvides': moduleProvides, 'IFoo': IFoo} @@ -2160,7 +2104,6 @@ class Test_getObjectSpecificationFallback(unittest.TestCase): def test_existing_provides_is_spec(self): from zope.interface.declarations import directlyProvides - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") def foo(): @@ -2181,7 +2124,6 @@ class Test_getObjectSpecificationFallback(unittest.TestCase): def test_existing_provides(self): from zope.interface.declarations import directlyProvides - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") class Foo: @@ -2194,7 +2136,6 @@ class Test_getObjectSpecificationFallback(unittest.TestCase): def test_wo_provides_on_class_w_implements(self): from zope.interface.declarations import implementer - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") @implementer(IFoo) @@ -2281,7 +2222,6 @@ class Test_providedByFallback(unittest.TestCase): def test_w_providedBy_valid_spec(self): from zope.interface.declarations import Provides - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") class Foo: @@ -2304,7 +2244,6 @@ class Test_providedByFallback(unittest.TestCase): def test_w_providedBy_invalid_spec_class_w_implements(self): from zope.interface.declarations import implementer - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") @implementer(IFoo) @@ -2341,7 +2280,6 @@ class Test_providedByFallback(unittest.TestCase): def test_w_providedBy_invalid_spec_w_provides_same_provides_on_class(self): from zope.interface.declarations import implementer - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") @implementer(IFoo) @@ -2539,7 +2477,6 @@ class ObjectSpecificationDescriptorFallbackTests(unittest.TestCase): def test_accessed_via_class(self): from zope.interface.declarations import Provides - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") class Foo: @@ -2552,7 +2489,6 @@ class ObjectSpecificationDescriptorFallbackTests(unittest.TestCase): def test_accessed_via_inst_wo_provides(self): from zope.interface.declarations import Provides from zope.interface.declarations import implementer - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") IBar = InterfaceClass("IBar") @@ -2569,7 +2505,6 @@ class ObjectSpecificationDescriptorFallbackTests(unittest.TestCase): from zope.interface.declarations import Provides from zope.interface.declarations import directlyProvides from zope.interface.declarations import implementer - from zope.interface.interface import InterfaceClass IFoo = InterfaceClass("IFoo") IBar = InterfaceClass("IBar") IBaz = InterfaceClass("IBaz") diff --git a/contrib/python/zope.interface/py3/zope/interface/tests/test_exceptions.py b/contrib/python/zope.interface/py3/zope/interface/tests/test_exceptions.py index 4346b1eadd3..959c772ae73 100644 --- a/contrib/python/zope.interface/py3/zope/interface/tests/test_exceptions.py +++ b/contrib/python/zope.interface/py3/zope/interface/tests/test_exceptions.py @@ -15,12 +15,15 @@ """ import unittest +import zope.interface -def _makeIface(): - from zope.interface import Interface - class IDummy(Interface): - pass +class IDummy(zope.interface.Interface): + pass + + +def _makeIface(): + from __tests__.tests.test_exceptions import IDummy return IDummy diff --git a/contrib/python/zope.interface/py3/zope/interface/tests/test_interface.py b/contrib/python/zope.interface/py3/zope/interface/tests/test_interface.py index b6f59c83312..5105c11575f 100644 --- a/contrib/python/zope.interface/py3/zope/interface/tests/test_interface.py +++ b/contrib/python/zope.interface/py3/zope/interface/tests/test_interface.py @@ -31,6 +31,7 @@ # pylint:disable=no-value-for-parameter import unittest +import zope.interface.interface from __tests__.tests import CleanUp from __tests__.tests import MissingSomeAttrs from __tests__.tests import OptimizationTestMixin @@ -38,6 +39,7 @@ from __tests__.tests import SubclassableMixin _marker = object() +HashMe = zope.interface.interface.InterfaceClass('HashMe') class Test_invariant(unittest.TestCase): @@ -1172,7 +1174,7 @@ class InterfaceClassTests(unittest.TestCase): self.assertEqual(iface.__reduce__(), 'PickleMe') def test___hash___normal(self): - iface = self._makeOne('HashMe') + from __tests__.tests.test_interface import HashMe as iface self.assertEqual( hash(iface), hash(('HashMe', '__tests__.tests.test_interface')) diff --git a/contrib/python/zope.interface/py3/zope/interface/tests/test_sorting.py b/contrib/python/zope.interface/py3/zope/interface/tests/test_sorting.py index e8e10eb080b..2e58ad05488 100644 --- a/contrib/python/zope.interface/py3/zope/interface/tests/test_sorting.py +++ b/contrib/python/zope.interface/py3/zope/interface/tests/test_sorting.py @@ -59,6 +59,9 @@ class Test(unittest.TestCase): # interfaces with equal names but different modules should sort by # module name from .m1 import I1 as m1_I1 + # We need to import I1 again to get a module path starting with `zope` + # instead of `interfaces`. + from __tests__.tests.test_sorting import I1 iface_list = [I1, m1_I1] iface_list.sort() self.assertEqual(iface_list, [m1_I1, I1]) |
