[Zope-CVS] CVS: Products/AdaptableStorage/gateway_sql/tests - testInterfaceImpl.py:1.1
Shane Hathaway
shane@zope.com
Tue, 10 Dec 2002 17:51:37 -0500
Update of /cvs-repository/Products/AdaptableStorage/gateway_sql/tests
In directory cvs.zope.org:/tmp/cvs-serv29122/gateway_sql/tests
Added Files:
testInterfaceImpl.py
Log Message:
With minor corrections, successfully created a CMF site in a Postgres database.
Awesome. :-)
=== Added File Products/AdaptableStorage/gateway_sql/tests/testInterfaceImpl.py ===
##############################################################################
#
# Copyright (c) 2002 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.
#
##############################################################################
"""Interface implementation tests
$Id: testInterfaceImpl.py,v 1.1 2002/12/10 22:51:37 shane Exp $
"""
import unittest
from types import ListType, TupleType
from Interface import Interface
from Interface.Verify import verifyClass
class InterfaceImplTests(unittest.TestCase):
def _testObjectImpl(self, c):
try:
impl = c.__implements__
if isinstance(impl, ListType) or isinstance(impl, TupleType):
for iface in impl:
self._verify(iface, c)
else:
self._verify(impl, c)
except:
print 'Bad implementation of', repr(c)
raise
def _testAllInModule(self, m):
for attr, value in m.__dict__.items():
if (hasattr(value, '__implements__') and
not Interface.isImplementedBy(value)):
self._testObjectImpl(value)
def _verify(self, iface, c):
verifyClass(iface, c)
for base in iface.getBases():
self._verify(base, c)
def testSerialPublicImplementations(self):
from Products.AdaptableStorage.gateway_sql import public
self._testAllInModule(public)
if __name__ == '__main__':
unittest.main()