configurationengine/source/testautomation/testautomation/tests/__init__.py
changeset 0 2e8eeb919028
child 3 e7e0ae78773e
equal deleted inserted replaced
-1:000000000000 0:2e8eeb919028
       
     1 #
       
     2 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 # All rights reserved.
       
     4 # This component and the accompanying materials are made available
       
     5 # under the terms of "Eclipse Public License v1.0"
       
     6 # which accompanies this distribution, and is available
       
     7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 #
       
     9 # Initial Contributors:
       
    10 # Nokia Corporation - initial contribution.
       
    11 #
       
    12 # Contributors:
       
    13 #
       
    14 # Description: 
       
    15 #
       
    16 
       
    17 import unittest, os, sys
       
    18 
       
    19 ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
       
    20 sys.path.append(os.path.join(ROOT_PATH,'../..'))
       
    21 
       
    22 # Find all unittest_*.py files in this folder
       
    23 import re
       
    24 __all__ = filter(lambda name: re.match(r'^unittest_.*\.py$', name) != None, os.listdir(ROOT_PATH))
       
    25 # Strip .py endings
       
    26 __all__ = map(lambda name: name[:-3], __all__)
       
    27 
       
    28 def collect_suite():  
       
    29     suite = unittest.TestSuite()
       
    30     for test_module in __all__:
       
    31         # Load the test module dynamically and add it to the test suite
       
    32         module = __import__(test_module)
       
    33         suite.addTests(unittest.TestLoader().loadTestsFromModule(module))
       
    34     return suite      
       
    35 
       
    36 def runtests():
       
    37     unittest.TextTestRunner(verbosity=2).run(collect_suite())
       
    38 
       
    39 if __name__ == '__main__':
       
    40     runtests()