]> git.llucax.com Git - software/mutest.git/commitdiff
Factor out get_fun() and get_val()
authorLeandro Lucarella <llucarella@integratech.com.ar>
Tue, 9 Dec 2008 19:16:32 +0000 (17:16 -0200)
committerLeandro Lucarella <llucarella@integratech.com.ar>
Fri, 12 Dec 2008 12:55:43 +0000 (10:55 -0200)
Those are useful functions that can be used in other places outside
TestCase class. Now TestSuite class use them too.

py/mutest

index 0c10bd788bd8b0442f457a22be149bff74520e24..707dc00d9813e6d0935ac01e329bde65625824a0 100755 (executable)
--- a/py/mutest
+++ b/py/mutest
@@ -37,6 +37,17 @@ def log(level, msg, *args):
                out.write((msg % args) + '\n')
 
 
+def get_fun(so, name, argtype=None, restype=None):
+       f = getattr(so, name)
+       f.argtypes = argtype
+       f.restype = restype
+       return f
+
+
+def get_val(so, name):
+       return c_int.in_dll(so, name).value
+
+
 #class SOError (Exception):
 #      pass
 
@@ -46,27 +57,18 @@ class TestCase(object):
        def __init__(self, so, name):
                self.so = so
                self.name = name
-               self.testcase = self.get_fun(name)
-               self.reset_counters = self.get_fun('mutest_reset_counters')
-               self.set_verbose_level = self.get_fun(
+               self.testcase = get_fun(so, name)
+               self.reset_counters = get_fun(so, 'mutest_reset_counters')
+               self.set_verbose_level = get_fun(so,
                                'mutest_set_verbose_level', argtype=[c_int])
 
        @property
        def passed_count(self):
-               return self.get_val('mutest_passed_count')
+               return get_val(self.so, 'mutest_passed_count')
 
        @property
        def failed_count(self):
-               return self.get_val('mutest_failed_count')
-
-       def get_fun(self, name, argtype=None, restype=None):
-               f = getattr(self.so, name)
-               f.argtypes = argtype
-               f.restype = restype
-               return f
-
-       def get_val(self, name):
-               return c_int.in_dll(self.so, name).value
+               return get_val(self.so, 'mutest_failed_count')
 
        def run(self):
                global verbose_level
@@ -97,8 +99,7 @@ class TestSuite (object):
                self.name = name
                self.so = so
                try:
-                       self.api_version = c_int.in_dll(self.so,
-                                       'mutest_api_version').value
+                       self.api_version = get_val(so, 'mutest_api_version')
                except ValueError:
                        self.api_version = 0
                        return