[Zope3-checkins] CVS: Zope3/src/zope/app/utilities/tests - test_interface.py:1.1.2.1 unitfixtures.py:1.1.2.1

Sidnei da Silva sidnei at x3ng.com.br
Fri Oct 3 17:02:31 EDT 2003


Update of /cvs-repository/Zope3/src/zope/app/utilities/tests
In directory cvs.zope.org:/tmp/cvs-serv12256/tests

Added Files:
      Tag: schema-utility-struct-failure
	test_interface.py unitfixtures.py 
Log Message:
Schema utility using new persistence.wrapper.Struct. Unfortunately it fails, but only when all tests are run

=== Added File Zope3/src/zope/app/utilities/tests/test_interface.py ===
##############################################################################
#
# Copyright (c) 2001, 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.
#
##############################################################################

import unittest
from zope.app.utilities.tests.unitfixtures import *  # hehehe
from zope.interface.interface import Attribute
from zope.interface.tests.test_interface import InterfaceTests as BaseTest
from zope.app.tests import setup

class InterfaceTests(BaseTest):

    def setUp(self):
        setup.placefulSetUp()

    def tearDown(self):
        setup.placefulTearDown()

class _I1(Schema):

    def f11(): pass
    def f12(): pass
    f12.optional = 1

_I1.addField('a1', Attribute("This is an attribute"))

class _I1_(_I1): pass
class _I1__(_I1_): pass

class _I2(_I1__):
    def f21(): pass
    def f22(): pass
    f23 = f22


def test_suite():
    return unittest.makeSuite(InterfaceTests)

def main():
    unittest.TextTestRunner().run(test_suite())

if __name__=="__main__":
    main()


=== Added File Zope3/src/zope/app/utilities/tests/unitfixtures.py ===
##############################################################################
#
# Copyright (c) 2001, 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.
#
##############################################################################
from zope.app.utilities.schema import SchemaUtility
from zope.interface.interface import Attribute
from zope.app.event.tests.placelesssetup import PlacelessSetup
# Setup EventPublication service.
PlacelessSetup().setUp()

Schema = SchemaUtility()
Schema.setName('Schema')

class mytest(Schema):
    pass

class C:
    def m1(self, a, b):
        "return 1"
        return 1

    def m2(self, a, b):
        "return 2"
        return 2

# testInstancesOfClassImplements




#  YAGNI IC=Interface.impliedInterface(C)
class IC(Schema):
    def m1(a, b):
        "return 1"

    def m2(a, b):
        "return 2"



C.__implements__=IC

class I1(Schema):
    def ma():
        "blah"

class I2(I1): pass

class I3(Schema): pass

class I4(Schema): pass

class A(I1.deferred()):
    __implements__=I1

class B:
    __implements__=I2, I3

class D(A, B): pass

class E(A, B):
    __implements__ = A.__implements__, C.__implements__


class FooInterface(Schema):
    """ This is an Abstract Base Class """

    def aMethod(foo, bar, bingo):
        """ This is aMethod """

    def anotherMethod(foo=6, bar="where you get sloshed", bingo=(1,3,)):
        """ This is anotherMethod """

    def wammy(zip, *argues):
        """ yadda yadda """

    def useless(**keywords):
        """ useless code is fun! """

FooInterface.addField('foobar', Attribute("fuzzed over beyond all recognition"))

class Foo:
    """ A concrete class """

    __implements__ = FooInterface,

    foobar = "yeah"

    def aMethod(self, foo, bar, bingo):
        """ This is aMethod """
        return "barf!"

    def anotherMethod(self, foo=6, bar="where you get sloshed", bingo=(1,3,)):
        """ This is anotherMethod """
        return "barf!"

    def wammy(self, zip, *argues):
        """ yadda yadda """
        return "barf!"

    def useless(self, **keywords):
        """ useless code is fun! """
        return "barf!"

foo_instance = Foo()

class Blah:
    pass

new = Schema.__class__
FunInterface = new('FunInterface')
BarInterface = new('BarInterface', [FunInterface])
BobInterface = new('BobInterface')
BazInterface = new('BazInterface', [BobInterface, BarInterface])




More information about the Zope3-Checkins mailing list