Merge "Topology manager - implementation of NodeChangeListener"
[openflowplugin.git] / test-scripts / tools / test_with_param_superclass.py
1 '''
2 Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3
4 This program and the accompanying materials are made available under the
5 terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 and is available at http://www.eclipse.org/legal/epl-v10.html
7
8 Created on Jan 24, 2014
9
10 @author: vdemcak
11 '''
12 import unittest
13
14
15 class OF_TestXmlInputs_Base( unittest.TestCase ):
16     """
17     Base TEST class extends unittest.TestCase and
18     it provides possibility to add parameters for 
19     all subclasses by call a static constructor:
20     
21     OF_TestXmlInputs_Base.load_file_name(sub_class_name, param)
22     """
23
24     def __init__( self, methodName = 'runTest', path_to_xml = None ):
25         """
26         private default constructor
27         """
28         super( OF_TestXmlInputs_Base, self ).__init__( methodName )
29         self.path_to_xml = path_to_xml
30
31     @staticmethod
32     def load_file_name( clazz, path_to_xml = None ):
33         """
34         static constructor for all subclasses with param
35         param -> path_to_xml (default None)
36         """
37         testloader = unittest.TestLoader()
38         testnames = testloader.getTestCaseNames( clazz )
39         suite = unittest.TestSuite()
40         for name in testnames:
41             suite.addTest( clazz( name, path_to_xml = path_to_xml ) )
42         return suite