import unittest import inspect import basic.constants as B import basic.toolHandling as toolHandling import tools.data_const as D import test.testtools import test.constants import basic.program import os import tools.data_tool HOME_PATH = test.constants.HOME_PATH DATA_PATH = test.constants.DATA_PATH OS_SYSTEM = test.constants.OS_SYSTEM # the list of TEST_FUNCTIONS defines which function will be really tested. # if you minimize the list you can check the specific test-function TEST_FUNCTIONS = ["test_01getKeyword", "test_02getStrDict"] PROGRAM_NAME = "clean_workspace" # with this variable you can switch prints on and off verbose = False class MyTestCase(unittest.TestCase): mymsg = "--------------------------------------------------------------" def test_01getKeyword(self): global mymsg actfunction = str(inspect.currentframe().f_code.co_name) cnttest = 0 if actfunction not in TEST_FUNCTIONS: return # job = basic.program.SimpleJob(PROGRAM_NAME) #job = test.testtools.getWorkspaceJob(PROGRAM_NAME) for x in ["_variants", "_variant", "subtable:_variants", "subtable:variants"]: res = tools.data_tool.getPurKeyword(x) self.assertEqual(res, "variant") def test_02getStrDict(self): global mymsg actfunction = str(inspect.currentframe().f_code.co_name) cnttest = 0 if actfunction not in TEST_FUNCTIONS: return job = basic.program.SimpleJob(PROGRAM_NAME) res = tools.data_tool.getStrDict("val1") self.assertEqual(len(res), 0) res = tools.data_tool.getStrDict("val1,val2") self.assertEqual(len(res), 0) res = tools.data_tool.getStrDict("key1:val1") self.assertEqual(len(res), 1) res = tools.data_tool.getStrDict("key1:val1,key2:val2") self.assertEqual(len(res), 2) res = tools.data_tool.getStrDict('"key1":"val1","key2":"val2"') self.assertEqual(len(res), 2) def test_zzz(self): print(MyTestCase.mymsg) if __name__ == '__main__': unittest.main()