[Zope-Checkins] CVS: Zope3/lib/python/Zope/Configuration/tests - testNames.py:1.1.2.1

Jim Fulton jim@zope.com
Fri, 16 Nov 2001 13:47:28 -0500


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

Added Files:
      Tag: Zope-3x-branch
	testNames.py 
Log Message:
configuration name resolution

=== Added File Zope3/lib/python/Zope/Configuration/tests/testNames.py ===

import unittest, sys

class NameTest(unittest.TestCase):

    def setUp(self):
        import Products_
        self.old=sys.modules.get('Products', None)
        sys.modules['Zope.Products']=Products_

    def tearDown(self):
        old=self.old
        if old is None: del sys.modules['Zope.Products']
        else: sys.modules['Zope.Products']=self.old
        
    def testProduct(self):
        from Zope.Configuration.name import resolve

        c=resolve('.Contact')
        self.assertEquals(c.n, 2)
        c=resolve('Zope.Products.Contact.Contact.Contact')
        self.assertEquals(c.n, 2)
        
    def testPackage(self):
        from Zope.Configuration.name import resolve

        c=resolve('Zope.Configuration.tests.Contact')
        self.assertEquals(c.n, 1)
        c=resolve('Zope.Configuration.tests.Contact.Contact.Contact')
        self.assertEquals(c.n, 1)
        


def test_suite():
    loader=unittest.TestLoader()
    return loader.loadTestsFromTestCase(NameTest)

if __name__=='__main__':
    unittest.TextTestRunner().run(test_suite())