Exemple #1
0
 def test_algorithm_registration_with_valid_object_succeeds(self):
     try:
         register_algorithm(IsAnAlgorithm)
         noerror = True
     except Exception:
         noerror = False
     self.assertTrue(noerror)
Exemple #2
0
 def test_algorithm_registration_with_invalid_object_throws(self):
     try:
         register_algorithm(NotAnAlgorithm)
         error = False
     except ValueError:
         error = True
     self.assertTrue(error)
     
Exemple #3
0
    def name(self):
        return 'CoolAlgorithm'
    
    def version(self):
        return 2
    
    def category(self):
        return "BestAlgorithms"
    
    def init_(self):
        pass
    
    def exec_(self):
        pass

register_algorithm(TestPyAlgDefaultAttrs)
register_algorithm(TestPyAlgOverriddenAttrs)

class PythonAlgorithmTest(unittest.TestCase):
        
    def raisesNothing(self, callable, *args): # unittest does not have this for some reason
        try:
            callable(*args)
        except RuntimeError, exc:
            self.fail(str(exc))
        
    def test_alg_with_default_attrs(self):
        self.raisesNothing(algorithm_mgr.create_unmanaged, "TestPyAlgDefaultAttrs")
        alg = algorithm_mgr.create_unmanaged("TestPyAlgDefaultAttrs")
        self.assertEquals(alg.name(), "TestPyAlgDefaultAttrs")
        self.assertEquals(alg.version(), 1)