[pytango] 185/483: Added TestSuite.py and TestSuiteTemplate.py

Sandor Bodo-Merle sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:14:39 UTC 2017


This is an automated email from the git hooks/post-receive script.

sbodomerle-guest pushed a commit to annotated tag bliss_8.10
in repository pytango.

commit ef664659c0c077e597996162f56474716e561fa8
Author: trogucki <trogucki at 4e9c00fd-8f2e-0410-aa12-93ce3db5e235>
Date:   Wed Jan 16 14:51:01 2013 +0000

    Added TestSuite.py and TestSuiteTemplate.py
    
    git-svn-id: http://svn.code.sf.net/p/tango-cs/code/bindings/PyTango/trunk@21910 4e9c00fd-8f2e-0410-aa12-93ce3db5e235
---
 tests/DevTest.py           | 133 +++++++++++++--------------------------
 tests/TangoRunner.py       |  25 +++++---
 tests/TestSuite.py         | 153 +++++++++++++++++++++++++++++++++++++++++++++
 tests/TestSuiteTemplate.py |  47 ++++++++++++++
 4 files changed, 263 insertions(+), 95 deletions(-)

diff --git a/tests/DevTest.py b/tests/DevTest.py
index 0dfedad..057afd3 100644
--- a/tests/DevTest.py
+++ b/tests/DevTest.py
@@ -88,7 +88,7 @@ class DevTest(PyTango.Device_4Impl):
         self.slow_actua = 0
         self.slow_actua_write = 0
         
-        self.enc_attr_data = bytearray([97,98,99,100])
+        self.enc_attr_data = bytes(bytearray([97,98,99,100]))
         self.enc_attr = ['Which format?', self.enc_attr_data] #''.join(chr(i) for i in self.enc_attr_data).encode('utf-8')]
         self.enc_format_toggle = False
         self.encoded_cmd_ctr = 0
@@ -2189,47 +2189,41 @@ class DevTest(PyTango.Device_4Impl):
 
 
     def write_Short_attr_w(self,the_att):
-        data = []
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
 
 #------------------------------------------------------------------
 
     def write_Long_attr_w(self,the_att):
         print "In write_Long_attr_w for attribute",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_Float_attr_w(self,the_att):
         print "In write_Float_attr_w for attribute",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_UShort_attr_w(self,the_att):
         print "In write_UShort_attr_w for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data;
 
 #------------------------------------------------------------------
 
     def write_UChar_attr_w(self,the_att):
         print "In write_UChar_attr_w for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_Short_attr_rw(self,the_att):
         print "In write_Short_attr_rw for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         self.attr_short_rw = data[0]
 
 #------------------------------------------------------------------
@@ -2241,16 +2235,14 @@ class DevTest(PyTango.Device_4Impl):
 
     def write_Long_attr_with_w2(self,the_att):
         print "In write_Long_attr_with_w for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         self.attr_long_rw2 = data[0]
 
 #------------------------------------------------------------------
 
     def write_Short_attr_w2(self,the_att):
         print "In write_Short_attr_w2 for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
@@ -2258,111 +2250,98 @@ class DevTest(PyTango.Device_4Impl):
     def write_Double_attr_w(self,the_att):
         print "In write_Double_attr_w for attribute ",the_att.get_name()
         data=[];
-        the_att.get_write_value(data)
+        the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_String_attr_w2(self,the_att):
         print "In write_String_attr_w2 for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_String_attr_w(self,the_att):
         print "In write_String_attr_w for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_Boolean_attr_w(self,the_att):
         print "In write_Boolean_attr_w for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_Short_spec_attr_w(self,the_att):
         print "In write_Short_spec_attr_w for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_Short_ima_attr_w(self,the_att):
         print "In write_Short_ima_attr_w for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_Long_spec_attr_w(self,the_att):
         print "In write_Long_spec_attr_w for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_Double_spec_attr_w(self,the_att):
         print "In write_Double_spec_attr_w for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_String_spec_attr_w(self,the_att):
         print "In write_String_spec_attr_w for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_Float_spec_attr_w(self,the_att):
         print "In write_Float_spec_attr_w for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_Boolean_spec_attr_w(self,the_att):
         print "In write_Boolean_spec_attr_w for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_UShort_spec_attr_w(self,the_att):
         print "In write_UShort_spec_attr_w for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_UChar_spec_attr_w(self,the_att):
         print "In write_UChar_spec_attr_w for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_String_ima_attr_w(self,the_att):
         print "In write_String_ima_attr_w for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
@@ -2372,88 +2351,77 @@ class DevTest(PyTango.Device_4Impl):
 
     def write_Float_ima_attr_w(self,the_att):
         print "In write_Float_ima_attr_w for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_UShort_ima_attr_w(self,the_att):
         print "In write_UShort_ima_attr_w for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_Short_spec_attr_rw(self,the_att):
         print "In write_Short_spec_attr_rw for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_String_spec_attr_rw(self,the_att):
         print "In write_String_spec_attr_rw for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_Float_spec_attr_rw(self,the_att):
         print "In write_Float_spec_attr_rw for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_UChar_spec_attr_rw(self,the_att):
         print "In write_UChar_spec_attr_rw for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_Short_ima_attr_rw(self,the_att):
         print "In write_Short_ima_attr_rw for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_String_ima_attr_rw(self,the_att):
         print "In write_String_ima_attr_rw for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_Boolean_ima_attr_rw(self,the_att):
         print "In write_Boolean_ima_attr_rw for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_UShort_ima_attr_rw(self,the_att):
         print "In write_UShort_ima_attr_rw for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_attr_asyn_write(self,the_att):
         print "In write_attr_asyn_write for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
         time.sleep(2)
 
@@ -2461,8 +2429,7 @@ class DevTest(PyTango.Device_4Impl):
 
     def write_attr_asyn_write_to(self,the_att):
         print "In write_attr_asyn_write_to for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
         time.sleep(4)
 
@@ -2470,8 +2437,7 @@ class DevTest(PyTango.Device_4Impl):
 
     def write_attr_asyn_write_except(self,the_att):
         print "In write_attr_asyn_write_except for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
         time.sleep(2)
         PyTango.Except.throw_exception("aaa","This is a test ","DevTest::write_attr_hardware")
@@ -2480,8 +2446,7 @@ class DevTest(PyTango.Device_4Impl):
 
     def write_slow_actuator(self,the_att):
         print "In write_slow_actuator for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         self.slow_actua = data[0]
         self.slow_actua_write = time.time()
         the_att.set_value(self.slow_actua)
@@ -2491,8 +2456,7 @@ class DevTest(PyTango.Device_4Impl):
 
     def write_fast_actuator(self,the_att):
         print "In write_fast_actuator for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         self.fast_actua = data[0]
         the_att.set_value(self.fast_actua)
         the_att.set_quality(PyTango.AttrQuality.ATTR_CHANGING)
@@ -2502,54 +2466,47 @@ class DevTest(PyTango.Device_4Impl):
 
     def write_Long64_attr_w(self,the_att):
         print "In write_Long64_attr_w for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_Long64_spec_attr_w(self,the_att):
         print "In write_Long64_spec_attr_w for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_Long64_ima_attr_w(self,the_att):
         print "In write_Long64_ima_attr_w for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_Long64_attr_rw(self,the_att):
         print "In write_Long64_attr_rw for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_Long64_spec_attr_rw(self,the_att):
         print "In write_Long64_spec_attr_rw for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
 #------------------------------------------------------------------
 
     def write_Long64_ima_attr_rw(self,the_att):
         print "In write_Long64_ima_attr_rw for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         print "Attribute value = ",data
 
     def write_Long_spec_attr_rw(self,the_att):
         print "In write_Long_spec_attr_rw for attribute ",the_att.get_name()
-        data=[]
-        the_att.get_write_value(data)
+        data = the_att.get_write_value()
         self.Long_spec_attr_rw = data
         print "Attribute value = ",data
 
diff --git a/tests/TangoRunner.py b/tests/TangoRunner.py
index e140ead..32fe246 100644
--- a/tests/TangoRunner.py
+++ b/tests/TangoRunner.py
@@ -22,15 +22,23 @@ def _printDict(obj):
         print("\t" + str(key) + " : " + str(value))
         
 def _hasFailed(result):
-    '''Checks if any failure occured'''
+    '''Checks if any failure occurred'''
     if result.__class__.__name__ == 'TangoTestResult' and (len(result.errors) != 0 or len(result.failures) != 0):
         return True
     return False
 
+def formatName(name):
+    newName = ''
+    for letter in name:
+        if letter.isupper():
+            newName += ' '
+        newName += letter
+    return newName
+
 class TangoTestSuite(TestSuite):
     '''Tango-tailored Test Suite class'''
-    def __init__(self):
-        super(TangoTestSuite, self).__init__()
+    def __init__(self, tests=()):
+        super(TangoTestSuite, self).__init__(tests)
         
     def __call__(self, *args, **kwds):
         if len(args) > 0:
@@ -47,7 +55,7 @@ class TangoTestSuite(TestSuite):
                 if suiteClass != None.__class__ and all(isinstance(test, TangoTestCase) and test.__class__ == suiteClass for test in self):
                     # print test suite name (only once), truncate the '__loop' suffix and show number of iterations
                     if self.loop == _loopSuite:
-                        suiteName = className
+                        suiteName = formatName(className)
                         if suiteName.endswith(_loopSuffix):
                             suiteName = suiteName[:-len(_loopSuffix)]
                             if _loopSuite > 1:
@@ -71,8 +79,8 @@ class TangoTestSuite(TestSuite):
 
 class TangoTestCase(TestCase):
     '''Tango-tailored Test Case class'''
-    def __init__(self):
-        super(TangoTestCase, self).__init__()
+    def __init__(self, methodName='runTest'):
+        super(TangoTestCase, self).__init__(methodName)
         
     def __call__(self, *args, **kwds):
         if len(args) > 0:
@@ -83,7 +91,7 @@ class TangoTestCase(TestCase):
                 result.loop = 0
                 # print test case name (only once), truncate the '__loop' suffix and show number of iterations
                 if self.loop == _loop and result.loopSuiteDone:
-                    caseName = self._testMethodName
+                    caseName = formatName(self._testMethodName)
                     if caseName.startswith('test_'):
                         caseName = caseName[len('test_'):]
                     if caseName.endswith(_loopSuffix):
@@ -140,6 +148,8 @@ class TangoTestResult(result.TestResult):
         self.dots = verbosity == 2
         self.tangoPrint = verbosity == 1
         self.descriptions = descriptions
+        self.loop = 0
+        self.loopSuite = 0
 
     def getDescription(self, test):
         testString = str(test).split(' ')
@@ -227,6 +237,7 @@ class TangoTestResult(result.TestResult):
 
     def printErrorList(self, flavour, errors):
         for test, err in errors:
+            self.stream.writeln()
             self.stream.writeln(self.separator1)
             self.stream.writeln("%s: %s" % (flavour,self.getDescription(test)))
             self.stream.writeln(self.separator2)
diff --git a/tests/TestSuite.py b/tests/TestSuite.py
new file mode 100644
index 0000000..1a2b9ec
--- /dev/null
+++ b/tests/TestSuite.py
@@ -0,0 +1,153 @@
+import sys
+import inspect
+import unittest
+import TangoRunner
+import PyTango
+from sets import Set
+import types
+
+# restore points
+_restore_points = Set()
+
+def restore_hash(cls, name):
+    if isinstance(cls, (type, types.ClassType)):
+        # the tearDownClass method case
+        return cls.__name__ + name
+    else:
+        # the test methods case
+        return cls.__class__.__name__ + name
+
+def restore_set(cls, name):
+    _restore_points.add(restore_hash(cls, name))
+    
+def restore_unset(cls, name):
+    # TODO: consider catching exceptions for silent execution
+    _restore_points.remove(restore_hash(cls, name))
+    
+def is_restore_set(cls, name):
+    return restore_hash(cls, name) in _restore_points
+    
+
+class AttrMisc(TangoRunner.TangoTestCase):
+    @classmethod
+    def setUpClass(self):
+        self.device1_name = 'dev/pytomasz/1'
+        self.device1 = PyTango.DeviceProxy(self.device1_name)
+    
+    @classmethod
+    def tearDownClass(self):
+        if is_restore_set(self, 'Float_spec_attr_rw'):
+            ai = self.device1.get_attribute_config('Float_spec_attr_rw')
+            ai.min_value = 'NaN'
+            ai.max_value = 'NaN'
+            ai.alarms.min_alarm = 'NaN'
+            ai.alarms.max_alarm = 'NaN'
+            self.device1.set_attribute_config(ai)
+        
+    def zzztest(self):
+        self.device1.state()
+        
+    def test_GetAttributeConfig(self):
+        ai = self.device1.get_attribute_config('Float_spec_attr_rw')
+        old_ai = PyTango.AttributeInfoEx(ai)
+        assert(ai.min_value == 'Not specified')
+        assert(ai.max_value == 'Not specified')
+        assert(ai.alarms.min_alarm == 'Not specified')
+        assert(ai.alarms.max_alarm == 'Not specified')
+        
+        ai.min_value = '3.5'
+        ai.max_value = '15.5'
+        ai.alarms.min_alarm = '4.2'
+        ai.alarms.max_alarm = '13.5'
+        self.device1.set_attribute_config(ai)
+        restore_set(self, 'Float_spec_attr_rw')
+        
+        new_ai = self.device1.get_attribute_config('Float_spec_attr_rw')
+        assert(new_ai.name == ai.name)
+        assert(new_ai.data_type == ai.data_type)
+        assert(new_ai.data_format == ai.data_format)
+        assert(new_ai.max_dim_x == ai.max_dim_x)
+        assert(new_ai.max_dim_y == ai.max_dim_y)
+        assert(new_ai.writable == ai.writable)
+        assert(new_ai.label == ai.label)
+        assert(new_ai.description == ai.description)
+        assert(new_ai.alarms.min_alarm == ai.alarms.min_alarm)
+        assert(new_ai.alarms.max_alarm == ai.alarms.max_alarm)
+        assert(new_ai.min_value == ai.min_value)
+        assert(new_ai.max_value == ai.max_value)
+        
+        ai.min_value = 'NaN'
+        ai.max_value = 'NaN'
+        ai.alarms.min_alarm = 'NaN'
+        ai.alarms.max_alarm = 'NaN'
+        self.device1.set_attribute_config(ai)
+        restore_unset(self, 'Float_spec_attr_rw')
+        
+        new_ai = self.device1.get_attribute_config('Float_spec_attr_rw')
+        assert(new_ai.name == old_ai.name)
+        assert(new_ai.data_type == old_ai.data_type)
+        assert(new_ai.data_format == old_ai.data_format)
+        assert(new_ai.max_dim_x == old_ai.max_dim_x)
+        assert(new_ai.max_dim_y == old_ai.max_dim_y)
+        assert(new_ai.writable == old_ai.writable)
+        assert(new_ai.label == old_ai.label)
+        assert(new_ai.description == old_ai.description)
+        assert(new_ai.alarms.min_alarm == old_ai.alarms.min_alarm)
+        assert(new_ai.alarms.max_alarm == old_ai.alarms.max_alarm)
+        assert(new_ai.min_value == old_ai.min_value)
+        assert(new_ai.max_value == old_ai.max_value)
+        
+        new_ai.min_value = '3.5'
+        new_ai.max_value = '15.5'
+        self.device1.set_attribute_config(new_ai)
+        restore_set(self, 'Float_spec_attr_rw')
+        
+        # TODO: choose one variant
+        # variant 1
+        with self.assertRaises(PyTango.DevFailed) as cm:
+            self.device1.write_attribute('Float_spec_attr_rw',[3.6,3.3,3.7])
+        assert(cm.exception.args[0].reason == 'API_WAttrOutsideLimit')
+        # variant 2
+        self.assertRaisesRegexp(PyTango.DevFailed,'reason = API_WAttrOutsideLimit',self.device1.write_attribute,'Float_spec_attr_rw',[3.6,3.3,3.7])
+        
+        self.assertRaisesRegexp(PyTango.DevFailed,'reason = API_WAttrOutsideLimit',self.device1.write_attribute,'Float_spec_attr_rw',[17.6])
+
+        new_ai.min_value = 'NaN'
+        new_ai.max_value = 'NaN'
+        new_ai.alarms.min_alarm = '6.0'
+        self.device1.set_attribute_config(new_ai)
+        
+        state = self.device1.state()
+        assert(state == PyTango.DevState.ALARM)
+        status = self.device1.status()
+        self.assertRegexpMatches(status,'ALARM')
+        self.assertRegexpMatches(status,'Float_spec_attr_rw')
+        
+        da = self.device1.read_attribute('Float_spec_attr_rw')
+        assert(da.quality == PyTango.AttrQuality.ATTR_ALARM)
+        
+        new_ai.alarms.min_alarm = 'NaN'
+        self.device1.set_attribute_config(new_ai)
+        
+        state = self.device1.state()
+        assert(state == PyTango.DevState.ON)
+        
+        da = self.device1.read_attribute('Float_spec_attr_rw')
+        assert(da.quality == PyTango.AttrQuality.ATTR_VALID)
+        
+
+if __name__ == '__main__':
+    # automatically detect tests (alphabetical order)
+    suites = []
+    testClasses = inspect.getmembers(sys.modules[__name__], inspect.isclass)
+    for name, test in testClasses:
+        if issubclass(test,TangoRunner.TangoTestCase):
+            suites.append(unittest.TestLoader().loadTestsFromTestCase(test))
+    
+#    # alternatively add test suite names here
+#    tests = [MyTest__loop]
+#    for test in tests:
+#        suites.append(unittest.TestLoader().loadTestsFromTestCase(test))
+
+    suite = TangoRunner.TangoTestSuite(suites)
+    TangoRunner.TangoTestRunner(loopSuite=2, loop=2).run(suite)
\ No newline at end of file
diff --git a/tests/TestSuiteTemplate.py b/tests/TestSuiteTemplate.py
new file mode 100644
index 0000000..32522ff
--- /dev/null
+++ b/tests/TestSuiteTemplate.py
@@ -0,0 +1,47 @@
+import sys
+import inspect
+import unittest
+import TangoRunner
+
+class MyTestSuite1(TangoRunner.TangoTestCase):
+    @classmethod
+    def setUpClass(self):
+        pass
+        
+    @classmethod
+    def tearDownClass(cls):
+        pass
+    
+    def setUp(self):
+        pass
+    
+    def tearDown(self):
+        pass
+    
+    def testMyTestCase1(self):
+        pass
+    
+    def testMyTestCase2__loop(self):
+        pass
+
+
+class MyTestSuite2__loop(TangoRunner.TangoTestCase):
+    def testMyTestCase3(self):
+        pass
+        
+
+if __name__ == '__main__':
+    # automatically detect tests (alphabetical order)
+    suites = []
+    testClasses = inspect.getmembers(sys.modules[__name__], inspect.isclass)
+    for name, test in testClasses:
+        if issubclass(test,TangoRunner.TangoTestCase):
+            suites.append(unittest.TestLoader().loadTestsFromTestCase(test))
+    
+#    # alternatively add test suite names here
+#    tests = [MyTest__loop]
+#    for test in tests:
+#        suites.append(unittest.TestLoader().loadTestsFromTestCase(test))
+
+    suite = TangoRunner.TangoTestSuite(suites)
+    TangoRunner.TangoTestRunner().run(suite)
\ No newline at end of file

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/pytango.git



More information about the debian-science-commits mailing list