Exemplo n.º 1
0
def testSchemes(modules=None, skip=None):
    '''
    Searches the given modules for methods named 'main'
    returns a test suite with one test for each main method
    If modules==None, all modules are searched
    '''
    
    suite = unittest.TestSuite()
    
    if modules==None:
        #Exclude unit tests
        modules = [mod for mod in all_unittests.find_modules() if not re.match(".*_test$", mod)]
        
    if skip==None:
        skip = []
    else:
        modules = list(set(modules).difference(set(skip)))
        modules.sort() 
    
    for name in modules:
        mod = all_unittests.load_module(name)
        if hasattr(mod, 'main'):
            try:
               case = unittest.FunctionTestCase(mod.main, None, None, mod.__name__)
               suite.addTest(case)
            except Exception as e:
               print("Stack Trace =>", e)
        else:
            skip.append(mod.__name__)
            
    #print("Testing  ", modules)
    #print("Skipping ", skip)
    return suite
Exemplo n.º 2
0
def testSchemes(modules=None, skip=None):
    '''
    Searches the given modules for methods named 'main'
    returns a test suite with one test for each main method
    If modules==None, all modules are searched
    '''
    
    suite = unittest.TestSuite()
    
    if modules==None:
        #Exclude unit tests
        modules = [mod for mod in all_unittests.find_modules() if not re.match(".*_test$", mod)]
        
    if skip==None:
        skip = []
    else:
        modules = list(set(modules).difference(set(skip)))
        modules.sort() 
    
    for name in modules:
        mod = all_unittests.load_module(name)
        if hasattr(mod, 'main'):
            try:
               case = unittest.FunctionTestCase(mod.main, None, None, mod.__name__)
               suite.addTest(case)
            except Exception as e:
               print("Stack Trace =>", e)
Exemplo n.º 3
0
    def testAllIBEnc(self):
        ibe_names = all_unittests.find_modules()
        ibe_classes = all_unittests.collectSubClasses(IBEnc, ibe_names)

        group = PairingGroup('../param/d224.param', 1024)
        for c in ibe_classes:
            print("Testing ", c)
            M = "test message"
            Test.myCorrectnessTest(c, group, M)
Exemplo n.º 4
0
 def testAllIBEnc(self):
     ibe_names = all_unittests.find_modules()
     ibe_classes = all_unittests.collectSubClasses(IBEnc, ibe_names)
     
     group = PairingGroup('MNT224', 1024)
     for c in ibe_classes:
         print("Testing ", c)
         M = "test message"
         Test.myCorrectnessTest(c, group, M)
Exemplo n.º 5
0
def autoDiscoverSchemes():
    '''Dynamically add a test method for each class'''
    ibe_names = all_unittests.find_modules()
    ibe_classes = all_unittests.collectSubClasses(IBEnc, ibe_names)

    for c in ibe_classes:
        name = "test" + c.__name__
        M = "test message"
        group = PairingGroup('../param/d224.param', 1024)
        func = lambda *args, **kwargs: Test.myCorrectnessTest(c, group, M)
        setattr(Test, name, func)
Exemplo n.º 6
0
def autoDiscoverSchemes():
    '''Dynamically add a test method for each class'''
    ibe_names   = all_unittests.find_modules()
    ibe_classes = all_unittests.collectSubClasses(IBEnc, ibe_names)
    
    for c in ibe_classes:
        name = "test" + c.__name__
        M = "test message"
        group = PairingGroup('../param/d224.param', 1024)
        func = lambda *args, **kwargs : Test.myCorrectnessTest(c, group, M)
        setattr(Test, name, func)