class RegistryTester(unittest.TestCase):
    def setUp(self):
        self.TESTS = range(ord("a"), ord("z"))
        self.TESTS = [chr(i) for i in self.TESTS]

        self.registry = CommandObjectRegistry()
        for name in self.TESTS:
            expr = CommandExpression(name)
            self.registry.addCommandObj(FakeCommand(name), expr)

    def tearDown(self):
        self.registry = None

    def testAlreadyRegistered(self):
        for name in self.TESTS:
            expr = CommandExpression(name)
            self.failUnlessRaises(CommandAlreadyRegisteredError,
                                  self.registry.addCommandObj,
                                  FakeCommand(name), expr)

    def testRegistered(self):
        for name in self.TESTS:
            cmd = self.registry.getCommandObj(name)
            self.failUnlessEqual(name, cmd.name)

        self.failUnlessEqual(set(self.registry.getCommandList()),
                             set(self.TESTS))
Exemplo n.º 2
0
class RegistryTester( unittest.TestCase ):
    def setUp( self ):
        self.TESTS = range( ord("a"), ord("z") )
        self.TESTS = [ chr(i) for i in self.TESTS ]

        self.registry = CommandObjectRegistry()
        for name in self.TESTS:
            expr = CommandExpression( name )
            self.registry.addCommandObj(  FakeCommand(name), expr )


    def tearDown( self ):
        self.registry = None

    def testAlreadyRegistered( self ):
        for name in self.TESTS:
            expr = CommandExpression( name )
            self.failUnlessRaises( CommandAlreadyRegisteredError,
                                   self.registry.addCommandObj,
                                   FakeCommand(name), expr )

    def testRegistered( self ):
        for name in self.TESTS:
            cmd = self.registry.getCommandObj( name )
            self.failUnlessEqual( name, cmd.name )

        self.failUnlessEqual( set( self.registry.getCommandList() ),
                              set( self.TESTS ) )
    def setUp(self):
        self.TESTS = range(ord("a"), ord("z"))
        self.TESTS = [chr(i) for i in self.TESTS]

        self.registry = CommandObjectRegistry()
        for name in self.TESTS:
            expr = CommandExpression(name)
            self.registry.addCommandObj(FakeCommand(name), expr)
Exemplo n.º 4
0
    def setUp( self ):
        self.TESTS = range( ord("a"), ord("z") )
        self.TESTS = [ chr(i) for i in self.TESTS ]

        self.registry = CommandObjectRegistry()
        for name in self.TESTS:
            expr = CommandExpression( name )
            self.registry.addCommandObj(  FakeCommand(name), expr )