[Zope3-checkins] CVS: Zope3/src/zope/configuration/tests - __init__.py:1.2 basetestdirectivesxml.py:1.2 directives.py:1.2 hooktestdummymodule.py:1.2 test_directivesxml.py:1.2 test_hookregistry.py:1.2 test_meta.py:1.2 test_metameta.py:1.2 test_metametafordocgen.py:1.2 test_multiplexml.py:1.2 test_names.py:1.2 test_xml.py:1.2

Jim Fulton jim@zope.com
Wed, 25 Dec 2002 09:14:06 -0500


Update of /cvs-repository/Zope3/src/zope/configuration/tests
In directory cvs.zope.org:/tmp/cvs-serv15352/src/zope/configuration/tests

Added Files:
	__init__.py basetestdirectivesxml.py directives.py 
	hooktestdummymodule.py test_directivesxml.py 
	test_hookregistry.py test_meta.py test_metameta.py 
	test_metametafordocgen.py test_multiplexml.py test_names.py 
	test_xml.py 
Log Message:
Grand renaming:

- Renamed most files (especially python modules) to lower case.

- Moved views and interfaces into separate hierarchies within each
  project, where each top-level directory under the zope package
  is a separate project.

- Moved everything to src from lib/python.

  lib/python will eventually go away. I need access to the cvs
  repository to make this happen, however.

There are probably some bits that are broken. All tests pass
and zope runs, but I haven't tried everything. There are a number
of cleanups I'll work on tomorrow.



=== Zope3/src/zope/configuration/tests/__init__.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:05 2002
+++ Zope3/src/zope/configuration/tests/__init__.py	Wed Dec 25 09:13:34 2002
@@ -0,0 +1,2 @@
+#
+# This file is necessary to make this directory a package.


=== Zope3/src/zope/configuration/tests/basetestdirectivesxml.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:05 2002
+++ Zope3/src/zope/configuration/tests/basetestdirectivesxml.py	Wed Dec 25 09:13:34 2002
@@ -0,0 +1,168 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Tests of the XML parsing machinery
+
+This mixin passes a series of sets of configuration directives
+to xmlconfig to make sure the right things happen.  The
+directives first define one or or more new directives, implemented
+by code in the Directives.py module, and then use those
+directives.  The tests check to make sure the expected actions
+were taken, or the expected errors raised.
+
+These tests test only the capabilities of the meta-directives
+implemented by the bootstrap versions.
+
+$Id$
+"""
+
+from cStringIO import StringIO
+from zope.configuration.meta import InvalidDirective
+from zope.configuration.xmlconfig import xmlconfig, testxmlconfig
+from zope.configuration.tests.directives import protections, done
+
+ns = 'http://www.zope.org/NS/Zope3/test'
+
+def makeconfig(metadirectives,directives):
+    return StringIO(
+        '''<zopeConfigure
+               xmlns="http://namespaces.zope.org/zope"
+               xmlns:test="%(ns)s">
+            <directives namespace="%(ns)s">
+              %(metadirectives)s
+            </directives>
+            %(directives)s
+            </zopeConfigure>''' % {
+                'metadirectives': metadirectives,
+                'directives': directives,
+                'ns': ns})
+
+
+class directiveTests:
+
+    def testDirective(self):
+        xmlconfig(makeconfig(
+            '''<directive
+                   name="doit"
+                   handler="zope.configuration.tests.directives.doit" />''',
+            '''<test:doit name="splat" />'''
+            ))
+        self.assertEqual(done, ['splat'])
+
+    def testSimpleComplexDirective(self):
+        xmlconfig(makeconfig(
+            '''<directive
+                   name="protectClass"
+                   handler="zope.configuration.tests.directives.protectClass">
+                 <subdirective name="protect" namespace="%s" />
+               </directive>''',
+            '''<test:protectClass
+                   name=".Contact" permission="splat" names="update" />'''
+            ))
+        self.assertEquals(protections, [(".Contact", "splat", 'update')])
+
+    def testComplexDirective(self):
+        xmlconfig(makeconfig(
+            '''<directive
+                   name="protectClass"
+                   handler="zope.configuration.tests.directives.protectClass">
+                 <subdirective name="protect" />
+               </directive>''',
+            '''<test:protectClass name=".Contact">
+               <test:protect permission="edit" names='update' />
+               <test:protect permission="view" names='name email' />
+               </test:protectClass>'''
+            ))
+        self.assertEquals(protections, [
+            (".Contact", "edit", 'update'),
+            (".Contact", "view", 'name email'),
+            ])
+
+    def testSubSubdirective(self):
+        xmlconfig(makeconfig(
+            '''<directive name="protectClass"
+                   handler="zope.configuration.tests.directives.protectClass">
+                 <subdirective name="subsub">
+                   <subdirective name="subsub">
+                     <subdirective name="subsub">
+                       <subdirective name="subsub">
+                         <subdirective name="protect"/>
+                       </subdirective>
+                     </subdirective>
+                   </subdirective>
+                 </subdirective>
+               </directive>''',
+            '''<test:protectClass
+                   name=".Contact" permission="splat" names="update"
+               >
+                 <test:subsub>
+                   <test:subsub>
+                     <test:subsub>
+                       <test:subsub>
+                         <test:protect permission="beep" names="update" />
+                       </test:subsub>
+                     </test:subsub>
+                   </test:subsub>
+                 </test:subsub>
+               </test:protectClass>'''
+            ))
+        self.assertEquals(protections, [(".Contact", "beep", 'update')])
+
+    def testHandlerMethod(self):
+        xmlconfig(makeconfig(
+            '''<directive name="protectClass"
+                   handler="zope.configuration.tests.directives.protectClass">
+                 <subdirective
+                     name="fish"
+                     handler_method="protect" />
+               </directive>''',
+            '''<test:protectClass name=".Contact">
+                 <test:fish permission="edit" names='update' />
+                 <test:fish permission="view" names='name email' />
+              </test:protectClass>'''
+            ))
+        self.assertEquals(protections, [
+            (".Contact", "edit", 'update'),
+            (".Contact", "view", 'name email'),
+            ])
+
+    def testBadNoPrefixComplexDirective(self):
+        self.assertRaises(
+            InvalidDirective,
+            testxmlconfig,
+            makeconfig(
+              '''<directive
+                    name="protectClass"
+                    handler="zope.configuration.tests.directives.protectClass">
+                   <subdirective name="protect" namespace="%s" />
+                 </directive>''',
+              '''<test:protectClass name=".Contact">
+                 <test:protect permission="edit" names='update' />
+                 <protect permission="view" names='name email' />
+                 </test:protectClass>
+              '''))
+
+    def testBadPrefixComplexDirective(self):
+        try: testxmlconfig(makeconfig(
+            '''<directive
+                   name="protectClass"
+                   handler="zope.configuration.tests.directives.protectClass">
+                 <subdirective name="protect" namespace="%s" />
+               </directive>''',
+            '''<test:protectClass name=".Contact">
+               <test2:protect permission="edit" names='update' />
+               </test:protectClass>''')),
+        except InvalidDirective, v:
+            self.assertEqual(str(v), "(None, u'test2:protect')")
+        else:
+            self.fail('Should have raised InvalidDirective')


=== Zope3/src/zope/configuration/tests/directives.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:05 2002
+++ Zope3/src/zope/configuration/tests/directives.py	Wed Dec 25 09:13:34 2002
@@ -0,0 +1,83 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""
+Test class for use by test modules
+
+$Id$
+"""
+
+from zope.interfaces.configuration import INonEmptyDirective
+from zope.interfaces.configuration import ISubdirectiveHandler
+
+protections=[]
+
+count = 0
+
+def _increment():
+    global count
+    count += 1
+
+def increment(_context):
+    return [(None, _increment, (), )]
+
+class protectClass:
+
+    __class_implements__ = INonEmptyDirective
+    __implements__ = ISubdirectiveHandler
+
+    def __init__(self, _context, name, permission=None, names=None):
+        self._name=name
+        self._permission=permission
+        self._names=names
+        self._children=[]
+        self.__context = _context
+
+    def __call__(self):
+        if not self._children:
+            p = self._name, self._permission, self._names
+            d = self._name, self._names
+            return [(d, protections.append, (p,))]
+        else:
+            return ()
+
+    def protect(self, _context, permission=None, names=None):
+        if permission is None: permission=self._permission
+        if permission is None: raise 'no perm'
+        p=self._name, permission, names
+        d=self._name, names
+        self._children.append(p)
+        return [(d, protections.append, (p,))]
+
+    def subsub(self, _context):
+        #Dummy subdirective-with-subdirectives.  Define this and you
+        #can define 'protect' subdirectives within it.  This lets
+        #us excercise the subdirectives-of-subdirectives code.
+        #If you put a protect inside a subsub, that'll set children,
+        #so when the parser calls us, __call__ will return ().
+        return self
+    subsub.__implements__ = INonEmptyDirective
+
+done = []
+
+def doit(_context, name):
+    return [('d', done.append, (name,))]
+
+def clearDirectives():
+    del protections[:]
+    del done[:]
+
+# Register our cleanup with Testing.CleanUp to make writing unit tests simpler.
+from zope.testing.cleanup import addCleanUp
+addCleanUp(clearDirectives)
+del addCleanUp


=== Zope3/src/zope/configuration/tests/hooktestdummymodule.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:05 2002
+++ Zope3/src/zope/configuration/tests/hooktestdummymodule.py	Wed Dec 25 09:13:34 2002
@@ -0,0 +1,26 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Hook test dummy module
+
+$Id$
+"""
+
+def dummyHookable():
+    return dummyHookable_hook()
+
+def dummyHookable_hook():
+    return "original implementation"
+
+def associatedDummy():
+    return dummyHookable()


=== Zope3/src/zope/configuration/tests/test_directivesxml.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:05 2002
+++ Zope3/src/zope/configuration/tests/test_directivesxml.py	Wed Dec 25 09:13:34 2002
@@ -0,0 +1,38 @@
+##############################################################################
+#
+# 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 sys, unittest
+from zope.configuration.tests.basetestdirectivesxml import directiveTests
+from zope.testing.cleanup import CleanUp
+
+class Test(CleanUp, unittest.TestCase, directiveTests): pass
+
+def test_suite():
+    loader=unittest.TestLoader()
+    return loader.loadTestsFromTestCase(Test)
+
+def run():
+    unittest.TextTestRunner().run(test_suite())
+
+def debug():
+    test_suite().debug()
+
+def pdb():
+    import pdb
+    pdb.run('debug()')
+
+if __name__=='__main__':
+    if len(sys.argv) < 2:
+        run()
+    else:
+        globals()[sys.argv[1]]()


=== Zope3/src/zope/configuration/tests/test_hookregistry.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:05 2002
+++ Zope3/src/zope/configuration/tests/test_hookregistry.py	Wed Dec 25 09:13:34 2002
@@ -0,0 +1,102 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+
+import unittest, sys
+
+def dummyHook():
+    return "hooked implementation"
+
+class HookRegistryTest(unittest.TestCase):
+
+    def testAddHookable(self):
+        from zope.configuration.hookregistry import HookRegistry
+
+        hookableAddr = (
+            'zope.configuration.tests.hooktestdummymodule.dummyHookable')
+
+        hookRegistry=HookRegistry()
+        hookRegistry.addHookable(hookableAddr)
+        hookables=hookRegistry.getHookables()
+        self.assertEquals(len(hookables), 1)
+        self.assertEquals(hookables[0][0], hookableAddr)
+        self.assertEquals(hookables[0][1],0)
+
+    def testAddDuplicateHookable(self):
+        from zope.configuration.hookregistry import HookRegistry
+        from zope.exceptions import DuplicationError
+
+        hookableAddr = (
+            'zope.configuration.tests.hooktestdummymodule.dummyHookable')
+        hookRegistry=HookRegistry()
+        hookRegistry.addHookable(hookableAddr)
+        self.assertRaises(DuplicationError, hookRegistry.addHookable,
+                          hookableAddr)
+
+    def testAddInvalidHookable(self):
+        from zope.configuration.hookregistry import HookRegistry, \
+             BadHookableError
+        hookRegistry=HookRegistry()
+        self.assertRaises(BadHookableError, hookRegistry.addHookable,
+                          'foo.bar.this.should.not.resolve.anywhere')
+        self.assertRaises(BadHookableError, hookRegistry.addHookable,
+                          'zope')
+        self.assertRaises(
+            BadHookableError, hookRegistry.addHookable,
+            'zope.configuration.hookregistry.hookregistry.addHookable')
+
+    def testAddHook(self):
+        from zope.configuration.hookregistry import \
+             HookRegistry, BadHookError, DuplicateHookError, \
+             MissingHookableError
+        from zope.configuration.tests.hooktestdummymodule \
+             import associatedDummy
+
+        dummyHook = 'zope.configuration.tests.test_hookregistry.dummyHook'
+        suite = 'zope.configuration.tests.test_hookregistry.test_suite'
+        hookableParent = 'zope.configuration.tests.hooktestdummymodule'
+        hookableLast = 'dummyHookable'
+        hookableAddr = '%s.%s' % (hookableParent, hookableLast)
+        old = __import__(hookableParent, {}, {}, ('__dict__',)) # for cleanup
+        old = getattr(old, hookableLast)
+        self.assertEquals(old(), "original implementation")
+
+        hookRegistry = HookRegistry()
+        hookRegistry.addHookable(hookableAddr)
+        self.assertRaises(BadHookError, hookRegistry.addHook, hookableAddr,
+                          'foo.bar.this.should.not.resolve.anywhere')
+        hookRegistry.addHook(hookableAddr, dummyHook)
+        new = __import__(hookableParent, {}, {}, ('__dict__',))
+        new = getattr(new, hookableLast)
+        self.assertEquals(new(), "hooked implementation")
+        self.assertEquals(associatedDummy(), "hooked implementation")
+        from zope.configuration.tests.hooktestdummymodule \
+             import associatedDummy as associatedDummyAgain
+        self.assertEquals(associatedDummyAgain(), "hooked implementation")
+        self.assertRaises(DuplicateHookError, hookRegistry.addHook,
+                          hookableAddr, suite)
+        self.assertRaises(MissingHookableError, hookRegistry.addHook,
+                          suite, dummyHook)
+        setattr(__import__(hookableParent, {}, {}, ('__dict__',)),
+                hookableLast, old) # cleanup
+
+def test_suite():
+    loader=unittest.TestLoader()
+    return loader.loadTestsFromTestCase(HookRegistryTest)
+
+if __name__=='__main__':
+    unittest.TextTestRunner().run(test_suite())


=== Zope3/src/zope/configuration/tests/test_meta.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:05 2002
+++ Zope3/src/zope/configuration/tests/test_meta.py	Wed Dec 25 09:13:34 2002
@@ -0,0 +1,91 @@
+##############################################################################
+#
+# 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.configuration.tests.directives \
+     import protectClass, protections, doit, done
+from zope.testing.cleanup import CleanUp # Base class w registry cleanup
+from zope.configuration import name
+
+ns='http://www.zope.org/NS/Zope3/test'
+
+class MetaTest(CleanUp, unittest.TestCase):
+
+    def testImport(self):
+        import zope.configuration.meta
+
+    def testDirective(self):
+        from zope.configuration.meta \
+             import register, registersub, begin, end, InvalidDirective
+
+        self.assertRaises(InvalidDirective, begin, None, name, (ns, 'doit'))
+
+        register((ns, 'doit'), doit)
+
+        subs = begin(None, (ns, 'doit'), name, name='splat')
+        (des, callable, args, kw), = end(subs)
+        self.assertEqual(des, 'd')
+        callable(*args)
+
+        self.failUnless(done==['splat'])
+
+    def testSimpleComplexDirective(self):
+        from zope.configuration.meta \
+             import register, registersub, begin, end, InvalidDirective
+
+        subs = register((ns, 'protectClass'), protectClass)
+        registersub(subs, (ns, 'protect'))
+
+        subs=begin(None, (ns, 'protectClass'), name,
+                   name=".Contact", permission="splat", names='update')
+
+        (des, callable, args, kw), = end(subs)
+        self.assertEqual(des, ('.Contact', 'update'))
+        callable(*args)
+
+        self.assertEquals(protections, [(".Contact", "splat", 'update')])
+
+    def testComplexDirective(self):
+        from zope.configuration.meta \
+             import register, registersub, begin, sub, end, InvalidDirective
+
+        subs = register((ns, 'protectClass'), protectClass)
+        registersub(subs, (ns, 'protect'))
+
+        subs = begin(None, (ns, 'protectClass'), name, name=".Contact")
+
+        actions = end(sub(subs, (ns, 'protect'), name,
+                          permission='edit', names='update'))
+        (des, callable, args, kw), = actions
+        self.assertEqual(des, ('.Contact', 'update'))
+        callable(*args)
+
+        actions = end(sub(subs, (ns, 'protect'), name,
+                          permission='view', names='name email'))
+        (des, callable, args, kw), = actions
+        self.assertEqual(des, ('.Contact', 'name email'))
+        callable(*args)
+
+        self.assertEqual(tuple(end(subs)), ())
+
+        self.assertEquals(protections, [
+            (".Contact", "edit", 'update'),
+            (".Contact", "view", 'name email'),
+            ])
+
+def test_suite():
+    loader=unittest.TestLoader()
+    return loader.loadTestsFromTestCase(MetaTest)
+
+if __name__=='__main__':
+    unittest.TextTestRunner().run(test_suite())


=== Zope3/src/zope/configuration/tests/test_metameta.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:05 2002
+++ Zope3/src/zope/configuration/tests/test_metameta.py	Wed Dec 25 09:13:34 2002
@@ -0,0 +1,89 @@
+##############################################################################
+#
+# 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 sys, unittest
+from zope.testing.cleanup import CleanUp
+from zope.configuration.xmlconfig import xmlconfig, testxmlconfig, XMLConfig
+from zope.configuration.tests.directives import done
+from zope.configuration.tests.basetestdirectivesxml import directiveTests
+from zope.configuration.tests.basetestdirectivesxml import makeconfig
+import zope.configuration
+
+class Test(CleanUp, unittest.TestCase, directiveTests):
+
+    def setUp(self):
+        XMLConfig('metameta.zcml', zope.configuration)()
+
+
+    def testDescription(self):
+        xmlconfig(makeconfig(
+            '''<directive
+                   name="doit"
+                   description="Something to Do"
+                   handler="zope.configuration.tests.directives.doit" />''',
+            '''<test:doit name="splat" />'''
+            ))
+        self.assertEqual(done, ['splat'])
+
+    def testAttribute(self):
+        xmlconfig(makeconfig(
+            '''<directive
+                   name="doit"
+                   handler="zope.configuration.tests.directives.doit"
+                   description="Something to Do"
+               >
+                 <attribute
+                     name="name"
+                     required="yes"
+                     description="Just Do It" />
+               </directive>''',
+            '''<test:doit name="splat" />'''
+            ))
+        self.assertEqual(done, ['splat'])
+
+    def testBadRequired(self):
+        self.assertRaises(
+            ValueError,
+            testxmlconfig,
+            makeconfig(
+                '''<directive
+                       name="doit"
+                       handler="zope.configuration.tests.directives.doit"
+                   >
+                     <attribute
+                         name="name"
+                         required="badvalue"
+                         description="Just Do It" />
+                   </directive>''',
+                '''<test:doit name="splat" />'''
+                ))
+
+def test_suite():
+    loader=unittest.TestLoader()
+    return loader.loadTestsFromTestCase(Test)
+
+def run():
+    unittest.TextTestRunner().run(test_suite())
+
+def debug():
+    test_suite().debug()
+
+def pdb():
+    import pdb
+    pdb.run('debug()')
+
+if __name__=='__main__':
+    if len(sys.argv) < 2:
+        run()
+    else:
+        globals()[sys.argv[1]]()


=== Zope3/src/zope/configuration/tests/test_metametafordocgen.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:05 2002
+++ Zope3/src/zope/configuration/tests/test_metametafordocgen.py	Wed Dec 25 09:13:34 2002
@@ -0,0 +1,109 @@
+##############################################################################
+#
+# 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 sys, unittest
+from zope.testing.cleanup import CleanUp
+from zope.configuration.xmlconfig import xmlconfig, testxmlconfig, XMLConfig
+from zope.configuration.meta import _directives
+from zope.configuration.metametaconfigurefordocgen import _metadataKey
+from zope.configuration.tests.directives import done
+from zope.configuration.tests.basetestdirectivesxml import directiveTests
+from zope.configuration.tests.basetestdirectivesxml import makeconfig, ns
+import zope.configuration
+
+class Test(CleanUp, unittest.TestCase, directiveTests):
+
+    def setUp(self):
+        XMLConfig('metameta.zcml', zope.configuration)()
+        XMLConfig('metametafordocgen.zcml', zope.configuration)()
+
+
+    def testDescription(self):
+        xmlconfig(makeconfig(
+            '''<directive
+                   name="doit"
+                   description="Just Do It"
+                   handler="zope.configuration.tests.directives.doit" />''',
+            '''<test:doit name="splat" />'''
+            ))
+        self.assertEqual(done, ['splat'])
+        md = _directives[(ns, 'doit')][1][_metadataKey]
+        self.assertEqual(md['description'], "Just Do It")
+
+    def testAttribute(self):
+        xmlconfig(makeconfig(
+            '''<directive
+                   name="doit"
+                   handler="zope.configuration.tests.directives.doit"
+               >
+                 <attribute
+                     name="name"
+                     required="Yes"
+                     description="Just Do It" />
+                 <attribute
+                     name="opt1"
+                     required="no"
+                     description="ho hum" />
+                 <attribute
+                     name="opt2"
+                     description="ho hummer" />
+               </directive>''',
+            '''<test:doit name="splat" />'''
+            ))
+        self.assertEqual(done, ['splat'])
+        md = _directives[(ns, 'doit')][1][_metadataKey]['attributes']['name']
+        self.assertEqual(md['description'],'Just Do It')
+        self.assertEqual(md['required'],'yes')
+        md = _directives[(ns, 'doit')][1][_metadataKey]['attributes']['opt1']
+        self.assertEqual(md['description'],'ho hum')
+        self.assertEqual(md['required'],'no')
+        md = _directives[(ns, 'doit')][1][_metadataKey]['attributes']['opt2']
+        self.assertEqual(md['description'],'ho hummer')
+        self.assertEqual(md['required'],'')
+
+    def testBadRequired(self):
+        self.assertRaises(
+            ValueError,
+            testxmlconfig,
+            makeconfig(
+                '''<directive
+                       name="doit"
+                       handler="zope.configuration.tests.directives.doit"
+                   >
+                     <attribute
+                         name="name"
+                         required="badvalue"
+                         description="Just Do It" />
+                   </directive>''',
+                '''<test:doit name="splat" />'''
+                ))
+
+def test_suite():
+    loader=unittest.TestLoader()
+    return loader.loadTestsFromTestCase(Test)
+
+def run():
+    unittest.TextTestRunner().run(test_suite())
+
+def debug():
+    test_suite().debug()
+
+def pdb():
+    import pdb
+    pdb.run('debug()')
+
+if __name__=='__main__':
+    if len(sys.argv) < 2:
+        run()
+    else:
+        globals()[sys.argv[1]]()


=== Zope3/src/zope/configuration/tests/test_multiplexml.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:05 2002
+++ Zope3/src/zope/configuration/tests/test_multiplexml.py	Wed Dec 25 09:13:34 2002
@@ -0,0 +1,157 @@
+##############################################################################
+#
+# 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, sys, os
+from tempfile import mktemp
+import zope.configuration.tests.directives
+from zope.configuration.tests.directives import protections, done
+from zope.configuration.xmlconfig import XMLConfig
+from zope.testing.cleanup import CleanUp # Base class w registry cleanup
+
+
+template = """<zopeConfigure
+   xmlns='http://namespaces.zope.org/zope'
+   xmlns:test='http://www.zope.org/NS/Zope3/test'>
+   <directives namespace="http://www.zope.org/NS/Zope3/test">
+   %s
+   </directives>
+   %s
+   </zopeConfigure>"""
+
+ns='http://www.zope.org/NS/Zope3/test'
+
+
+class Test(CleanUp, unittest.TestCase):
+
+    def testNormal(self):
+        f2=tfile(template % ('',
+            '''
+            <test:protectClass
+            name=".Contact" permission="splat" names="update"
+            />
+            <test:protectClass
+            name=".Contact" permission="splat" names="update2"
+            />
+            '''), 'f2')
+
+        f1=tfile(template % (
+            '''<directive name="protectClass" namespace="%s"
+            handler="zope.configuration.tests.directives.protectClass">
+            <subdirective name="protect" namespace="%s" />
+            </directive>
+            <directive name="increment" namespace="%s"
+            handler="zope.configuration.tests.directives.increment">
+            </directive>
+            ''' % (ns, ns, ns),
+
+            '''
+            <test:protectClass
+            name=".Contact" permission="splat" names="update"
+            />
+            <test:increment />
+            <test:increment />
+            <test:increment />
+            <include file="%s"/>
+            ''' % f2), 'f1')
+
+        XMLConfig(str(f1))()
+
+        self.assertEquals(protections, [
+            (".Contact", "splat", 'update'),
+            (".Contact", "splat", 'update2'),
+            ])
+
+        self.assertEquals(zope.configuration.tests.directives.count, 3)
+
+    def testConflicting(self):
+        f2=tfile(template % ('',
+            '''
+            <test:protectClass
+            name=".Contact" permission="splat" names="update"
+            />
+            <test:protectClass
+            name=".Contact" permission="splat" names="update2"
+            />
+            '''), 'f2')
+        f3=tfile(template % ('',
+            '''
+            <test:protectClass
+            name=".Contact" permission="splat" names="update2"
+            />
+            '''), 'f3')
+
+        f1=tfile(template % (
+            '''<directive name="protectClass" namespace="%s"
+            handler="zope.configuration.tests.directives.protectClass">
+            <subdirective name="protect" namespace="%s" />
+            </directive>''' % (ns, ns),
+            '''
+            <test:protectClass
+            name=".Contact" permission="splat" names="update"
+            />
+            <include file="%s"/>
+            <include file="%s"/>
+            ''' % (f2, f3)), 'f1')
+
+        x=XMLConfig(str(f1))
+
+        from zope.configuration.xmlconfig import ZopeConfigurationConflictError
+
+        self.assertRaises(ZopeConfigurationConflictError, x)
+
+        self.assertEquals(protections, [])
+
+
+    def testConflicting_in_same_location(self):
+        f1=tfile(template % (
+            '''<directive name="protectClass" namespace="%s"
+            handler="zope.configuration.tests.directives.protectClass">
+            <subdirective name="protect" namespace="%s" />
+            </directive>''' % (ns, ns),
+            '''
+            <test:protectClass
+            name=".Contact" permission="splat" names="update"
+            />
+            <test:protectClass
+            name=".Contact" permission="splat" names="update"
+            />
+            '''), 'f1')
+
+        x=XMLConfig(str(f1))
+
+        from zope.configuration.xmlconfig import ZopeConfigurationConflictError
+
+        self.assertRaises(ZopeConfigurationConflictError, x)
+
+        self.assertEquals(protections, [])
+
+
+
+class tfile:
+
+    def __init__(self, string, suffix):
+        self.name = mktemp(suffix)
+        file = open(self.name, 'w')
+        file.write(string)
+        file.close()
+
+    def __str__(self): return self.name
+
+    def __del__(self): os.remove(self.name)
+
+def test_suite():
+    loader=unittest.TestLoader()
+    return loader.loadTestsFromTestCase(Test)
+
+if __name__=='__main__':
+    unittest.TextTestRunner().run(test_suite())


=== Zope3/src/zope/configuration/tests/test_names.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:06 2002
+++ Zope3/src/zope/configuration/tests/test_names.py	Wed Dec 25 09:13:34 2002
@@ -0,0 +1,111 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+
+import unittest, sys
+
+class NameTest(unittest.TestCase):
+
+    def setUp(self):
+
+        from zope.configuration.tests import products_
+        self.old = sys.modules.get('zopeproducts', None)
+        sys.modules['zopeproducts'] = products_
+
+    def tearDown(self):
+        old = self.old
+        if old is None:
+            del sys.modules['zopeproducts']
+        else:
+            sys.modules['zopeproducts']=self.old
+
+    def testProductPath(self):
+        from zope.configuration.name import resolve
+
+        c=resolve('.contact.contact.Contact')
+        self.assertEquals(c.n, 2)
+        c=resolve('zopeproducts.contact.contact.Contact')
+        self.assertEquals(c.n, 2)
+
+    def testPackagePath(self):
+        from zope.configuration.name import resolve
+
+        c=resolve('zope.configuration.tests.contact')
+        import zope.configuration.tests.contact
+        self.assertEquals(c, zope.configuration.tests.contact)
+
+        c=resolve('zope.configuration.tests.contact.contact.Contact')
+        self.assertEquals(c.n, 1)
+        c=resolve('zope.configuration.tests.contact.contact.Contact')
+        self.assertEquals(c.n, 1)
+
+    def testNoDots(self):
+        from zope.configuration.name import resolve
+        import zope
+        c=resolve('zope')
+
+        self.assertEquals(id(c), id(zope))
+
+    def testPackage(self):
+        from zope.configuration.name import resolve
+        c=resolve('zope.configuration.tests')
+        import zope.configuration.tests
+
+        self.assertEquals(id(c), id(zope.configuration.tests))
+
+    nameSet={
+        ('zope.configuration.tests','Noplace'):
+        'zope.configuration.tests',
+        ('zope.configuration.tests.tests','Noplace'):
+        'zope.configuration.tests+',
+        ('zope.configuration.tests.tests.tests','Noplace'):
+        'zope.configuration.tests+',
+        ('zope.configuration.tests.tests.tests.','Noplace'):
+        'zope.configuration.tests+',
+        ('zope.configuration.tests+','Noplace'):
+        'zope.configuration.tests+',
+        ('zope.configuration.tests.tests.tests+','Noplace'):
+        'zope.configuration.tests+',
+        ('zope.configuration.tests.','Noplace'):
+        'zope.configuration.tests+',
+        ('.tests','zope.configuration'):
+        'zope.configuration.tests',
+        ('.tests.tests','zope.configuration'):
+        'zope.configuration.tests+',
+        ('.tests.tests.tests','zope.configuration'):
+        'zope.configuration.tests+',
+        ('.tests.tests.tests.','zope.configuration'):
+        'zope.configuration.tests+',
+        ('.tests+','zope.configuration'):
+        'zope.configuration.tests+',
+        ('.tests.tests.tests+','zope.configuration'):
+        'zope.configuration.tests+',
+        ('.tests.','zope.configuration'):
+        'zope.configuration.tests+'
+        }
+
+    def testNormalizedName(self):
+        from zope.configuration.name import getNormalizedName
+        for args in self.nameSet:
+            self.assertEquals(self.nameSet[args], getNormalizedName(*args))
+
+def test_suite():
+    loader=unittest.TestLoader()
+    return loader.loadTestsFromTestCase(NameTest)
+
+if __name__=='__main__':
+    unittest.TextTestRunner().run(test_suite())


=== Zope3/src/zope/configuration/tests/test_xml.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:06 2002
+++ Zope3/src/zope/configuration/tests/test_xml.py	Wed Dec 25 09:13:34 2002
@@ -0,0 +1,125 @@
+##############################################################################
+#
+# 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 sys, unittest
+from cStringIO import StringIO
+
+# Caution:  tempfile.NamedTemporaryFile cannot be used on Windows, because
+# the tests here want to open the file more than once.  You can't do that
+# with an O_TEMPORARY file on Win2K (or higher).
+import tempfile
+
+class TempFile:
+    from os import remove
+
+    def __init__(self):
+        self.file = open(tempfile.mktemp(), 'w')
+        self.closed = 0
+    def write(self,buffer):
+        self.file.write(buffer)
+    def _name(self):
+        return self.file.name
+    name = property(_name)
+    def flush(self):
+        self.file.flush()
+    def close(self):
+        if not self.closed:
+            self.file.close()
+            self.remove(self.file.name)
+            self.closed = 1
+    def __del__(self):
+        self.close()
+
+from zope.configuration.xmlconfig import xmlconfig
+from zope.configuration.xmlconfig import testxmlconfig
+from zope.configuration.meta import InvalidDirective, BrokenDirective
+from zope.testing.cleanup import CleanUp
+
+class Test(CleanUp, unittest.TestCase):
+
+    def testInclude(self):
+        file = TempFile()
+        name = file.name
+        file.write(
+            """<zopeConfigure xmlns='http://namespaces.zope.org/zope'>
+                 <include
+                     package="zope.configuration.tests.contact"
+                     file="contact.zcml" />
+               </zopeConfigure>""")
+        file.flush()
+        from zope.configuration.xmlconfig import XMLConfig
+        x = XMLConfig(name)
+        x()
+        file.close()
+
+    def testIncludeAll(self):
+        file = TempFile()
+        name = file.name
+        file.write(
+            """<zopeConfigure xmlns='http://namespaces.zope.org/zope'>
+                 <include
+                     package="zope.configuration.tests.*"
+                     file="contact.zcml" />
+               </zopeConfigure>""")
+        file.flush()
+        from zope.configuration.xmlconfig import XMLConfig
+        x = XMLConfig(name)
+        x()
+        file.close()
+
+    def testIncludeNoPackageAndIncluderNoPackage(self):
+        from os.path import split
+        file = TempFile()
+        full_name = file.name
+        file1 = TempFile()
+        full_name1 = file1.name
+        name1 = split(full_name1)[-1]
+
+        file.write(
+            """<zopeConfigure xmlns='http://namespaces.zope.org/zope'>
+                 <include file="%s" />
+               </zopeConfigure>""" % name1)
+        file.flush()
+        file1.write(
+            """<zopeConfigure xmlns='http://namespaces.zope.org/zope'>
+                 <include
+                     package="zope.configuration.tests.contact"
+                     file="contact.zcml" />
+               </zopeConfigure>""")
+        file1.flush()
+        from zope.configuration.xmlconfig import XMLConfig
+        x = XMLConfig(full_name)
+        x()
+
+        file.close()
+        file1.close()
+
+def test_suite():
+    loader=unittest.TestLoader()
+    return loader.loadTestsFromTestCase(Test)
+
+def run():
+    unittest.TextTestRunner().run(test_suite())
+
+def debug():
+    test_suite().debug()
+
+def pdb():
+    import pdb
+    pdb.run('debug()')
+
+if __name__=='__main__':
+    if len(sys.argv) < 2:
+        run()
+    else:
+        globals()[sys.argv[1]]()