Skip to content

Commit

Permalink
Port remaining doctest to unittest.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Jun 8, 2017
1 parent 1d684b2 commit 916b964
Showing 1 changed file with 48 additions and 6 deletions.
54 changes: 48 additions & 6 deletions src/zope/interface/tests/test_odd_declarations.py
Expand Up @@ -212,9 +212,51 @@ class C2(C1):
self.assertEqual([i.getName() for i in implementedBy(C2)],
['I3', 'I2'])

def test_suite():
import doctest
return unittest.TestSuite((
unittest.defaultTestLoader.loadTestsFromName(__name__),
doctest.DocTestSuite(odd),
))
def test_odd_metaclass_that_doesnt_subclass_type(self):
# This was originally a doctest in odd.py.
# It verifies that the metaclass the rest of these tests use
# works as expected.

# This is used for testing support for ExtensionClass in new interfaces.

class A(object):
a = 1

A = odd.MetaClass('A', A.__bases__, A.__dict__)

class B(object):
b = 1

B = odd.MetaClass('B', B.__bases__, B.__dict__)

class C(A, B):
pass

self.assertEqual(C.__bases__, (A, B))

a = A()
aa = A()
self.assertEqual(a.a, 1)
self.assertEqual(aa.a, 1)

aa.a = 2
self.assertEqual(a.a, 1)
self.assertEqual(aa.a, 2)

c = C()
self.assertEqual(c.a, 1)
self.assertEqual(c.b, 1)

c.b = 2
self.assertEqual(c.b, 2)

C.c = 1
self.assertEqual(c.c, 1)
c.c

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))

self.assertIs(C.__class__.__class__, C.__class__)

0 comments on commit 916b964

Please sign in to comment.