[Zope-Checkins] CVS: Zope3/lib/python/Zope/ComponentArchitecture/tests - testFactory.py:1.1.2.1

Fred Drake Jr fdrake@acm.org
Tue, 20 Nov 2001 15:39:34 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/ComponentArchitecture/tests
In directory cvs.zope.org:/tmp/cvs-serv5416/tests

Added Files:
      Tag: Zope-3x-branch
	testFactory.py 
Log Message:
Test the factory machinery.

=== Added File Zope3/lib/python/Zope/ComponentArchitecture/tests/testFactory.py ===
"""Test the provideFactory function."""

import unittest

from Zope.ComponentArchitecture.IFactory import IFactory
from Zope.ComponentArchitecture import provideFactory, createObject

class MyThing:
    pass

class MyFactory:
    __implements__ = IFactory

    def __call__(self):
        return MyThing()


class ProvideFactoryTestCase(unittest.TestCase):
    def test_provide_factory(self):
        provideFactory("Some.Object", MyFactory())
        thing = createObject("Some.Object")
        self.assert_(isinstance(thing, MyThing))


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