Skip to content

Commit

Permalink
test #165: problem with local defined classes in same module
Browse files Browse the repository at this point in the history
(cherry picked from commit 31b17ea)
  • Loading branch information
jensens committed Feb 5, 2020
1 parent 31aac9e commit b3debd7
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/zope/interface/tests/test_interface.py
Expand Up @@ -885,7 +885,6 @@ def test_comparison_with_same_named_instance_in_other_module(self):
self.assertFalse(one > other)
self.assertTrue(other > one)


class InterfaceTests(unittest.TestCase):

def test_attributes_link_to_interface(self):
Expand Down Expand Up @@ -1848,6 +1847,34 @@ class C(object):
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):

Expand Down

0 comments on commit b3debd7

Please sign in to comment.