[Zope3-checkins] CVS: Packages3/Interface/tests -
test_ExtentionClass.py:1.1
Jim Fulton
jim at zope.com
Wed Jan 21 16:58:48 EST 2004
Update of /cvs-repository/Packages3/Interface/tests
In directory cvs.zope.org:/tmp/cvs-serv21701/src/Interface/tests
Added Files:
test_ExtentionClass.py
Log Message:
Changed the way providedBy worked to fix a bug in handling old-style
extension classes.
Note that the test is actually in Packages3/Interfaces, the facade
that emulated Z2 interfaces using Z3 interfaces. It was easier
to write the test there, because I could actually write it using
extension class. :) My attempts at simulating EC failed and are too
hard to understand, at least today.
=== Added File Packages3/Interface/tests/test_ExtentionClass.py ===
##############################################################################
#
# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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 to make sure the interface facade works with old-style ExtensionClass
$Id: test_ExtentionClass.py,v 1.1 2004/01/21 21:58:47 jim Exp $
"""
import unittest
import Interface.Implements
try:
from ExtensionClass import Base
except ImportError:
print 'Old-style ExtensionClass is not installed. Skipping tests'
Base = object
def test_classic_declarations_work_in_subclass_that_is_ExtensionClass():
"""
>>> class I1(Interface.Interface):
... pass
>>> class C:
... __implements__ = I1
>>> I1.isImplementedBy(C())
True
>>> chicken = []
>>> ifaces = []
>>> Interface.Implements.visitImplements(C.__implements__, chicken,
... ifaces.append)
>>> [iface.__name__ for iface in ifaces]
['I1']
>>> class I2(Interface.Interface):
... pass
>>> class E(Base, C):
... __implements__ = I2
>>> I2.isImplementedBy(E())
True
>>> ifaces = []
>>> Interface.Implements.visitImplements(E.__implements__, chicken,
... ifaces.append)
>>> [iface.__name__ for iface in ifaces]
['I2']
>>> I2.isImplementedBy(E())
True
"""
if issubclass(Base, object):
# Skip tests
def test_suite():
return unittest.TestSuite()
else:
from doctest import DocTestSuite
def test_suite():
return unittest.TestSuite((
DocTestSuite(),
))
if __name__ == '__main__': unittest.main()
More information about the Zope3-Checkins
mailing list