summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJens W. Klein <jk@kleinundpartner.at>2020-02-05 11:42:27 +0100
committerJens W. Klein <jk@kleinundpartner.at>2020-02-05 11:46:59 +0100
commit31b17ea5ba11815bf4bcfe57fd5cb1d24b66b7e0 (patch)
treef7a7bee5e0dc237f587e3faff5a6b451efd3e0a5 /src
parent79be400cc9a5a8525db9e7869e401aede3d01d72 (diff)
downloadzope-interface-31b17ea5ba11815bf4bcfe57fd5cb1d24b66b7e0.tar.gz
test #165: problem with local defined classes in same module
Diffstat (limited to 'src')
-rw-r--r--src/zope/interface/tests/test_interface.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/zope/interface/tests/test_interface.py b/src/zope/interface/tests/test_interface.py
index 3bf26dc..ece483a 100644
--- a/src/zope/interface/tests/test_interface.py
+++ b/src/zope/interface/tests/test_interface.py
@@ -885,7 +885,6 @@ class InterfaceClassTests(unittest.TestCase):
self.assertFalse(one > other)
self.assertTrue(other > one)
-
class InterfaceTests(unittest.TestCase):
def test_attributes_link_to_interface(self):
@@ -1848,6 +1847,34 @@ class InterfaceTests(unittest.TestCase):
finally:
adapter_hooks[:] = old_adapter_hooks
+ def test_local_interfaces_with_same_name_and_module_are_different(self):
+ # see https://github.com/zopefoundation/zope.interface/issues/165
+ from zope.interface import Interface
+
+ def make_IFoo_1():
+ class IFoo(Interface):
+ pass
+
+ return IFoo
+
+ def make_IFoo_2():
+ class IFoo(Interface):
+ pass
+
+ return IFoo
+
+ ifoo1 = make_IFoo_1()
+ ifoo2 = make_IFoo_2()
+ self.assertFalse(ifoo1 is ifoo2)
+ self.assertNotEqual(ifoo1, ifoo2)
+ self.assertIn(ifoo1, Interface._dependents)
+ self.assertIn(ifoo2, Interface._dependents)
+ self.asserNotEqual(
+ list(Interface._dependents).index(ifoo1),
+ list(Interface._dependents).index(ifoo2),
+ )
+ self.assertNotEqual(hash(ifoo1), hash(ifoo2))
+
class AttributeTests(ElementTests):