TestCenter Reference
TestCaseGeneric.py
Go to the documentation of this file.
2# Copyright 2009, MeVis Medical Solutions AG
3#
4# The user may use this file in accordance with the license agreement provided with
5# the Software or, alternatively, in accordance with the terms contained in a
6# written agreement between the user and MeVis Medical Solutions AG.
7#
8# For further information use the contact form at https://www.mevislab.de/contact
9#
10
13
14# -- system imports ----------------------------------------------------------------------------{{{-
15import xml.etree.cElementTree as etree
16# ----------------------------------------------------------------------------------------------}}}-
17
18# -- local imports -----------------------------------------------------------------------------{{{-
19import mevis
20from .TestCase import TestCase
21from TestSupport.TestHelper import TestHelper
22# ----------------------------------------------------------------------------------------------}}}-
23
24# -- class GenericTestCase ---------------------------------------------------------------------{{{-
25
27 # -- def __init__ ----------------------------------------------------------------------------{{{-
28
29 def __init__ (self, testCaseName, moduleName=None):
30 self._testCaseType_testCaseType = 'GenericTestCase'
31 self._moduleName = moduleName
32 TestCase.__init__(self, testCaseName)
33 # --------------------------------------------------------------------------------------------}}}-
34
35 # -- def run ---------------------------------------------------------------------------------{{{-
36
37 def run (self, xmlNode):
38 if not self._moduleName:
39 raise Exception("No module name set for test %s." % (self._testCaseName_testCaseName))
40 self._testHelper.setModuleName(self._moduleName)
41 TestCase.run(self, xmlNode)
42 self._testHelper.setModuleName(None)
43
44 # --------------------------------------------------------------------------------------------}}}-
45
46 # -- def __testModule ------------------------------------------------------------------------{{{-
47
50 def __testModule (self, moduleName):
51 if "testModule" in self._ctx.callableFunctions():
52 return self._ctx.call("testModule", [moduleName,])
53 return True
54 # --------------------------------------------------------------------------------------------}}}-
55
56 # -- def getName -----------------------------------------------------------------------------{{{-
57
58 def getName (self):
59 return "%s::%s" % (self._testCaseName_testCaseName, self._moduleName)
60 # --------------------------------------------------------------------------------------------}}}-
61
62 # -- def getModulesToTest --------------------------------------------------------------------{{{-
63
64 def getModulesToTest (self, moduleList, packageList):
65 availableModuleList = []
66
67 for packageIdentifier in packageList:
68 availableModuleList.extend(mevis.MLAB.allModulesForPackageIdentifier(packageIdentifier))
69
70 # Testing myself wouldn't be a good idea (recursive adding of module is not supported).
71 testerName = TestHelper.getInstance().getGlobalContext().name
72 if testerName in availableModuleList:
73 availableModuleList.remove(testerName)
74
75 modulesToTest = []
76 modulesNotToTest = []
77 for moduleName in moduleList:
78 if moduleName in availableModuleList:
79 if self.__testModule(moduleName):
80 modulesToTest.append(moduleName)
81 else:
82 modulesNotToTest.append(moduleName)
83 return modulesToTest, modulesNotToTest
84 # --------------------------------------------------------------------------------------------}}}-
85# ----------------------------------------------------------------------------------------------}}}-
86
The implementation of the TestCase superclass for generic testing.
getName(self)
Return the name of the test case.
run(self, xmlNode)
Prior to running the actual test the module name is set to the result node.
getModulesToTest(self, moduleList, packageList)
Get the list of modules to test.
__init__(self, testCaseName, moduleName=None)
The default constructor.
The superclass for the different test case categories.
Definition TestCase.py:88
_testHelper
The instance of the TestHelper singleton.
Definition TestCase.py:93
_ctx
The TestCase's context.
Definition TestCase.py:91
_testCaseType
The type of the test case.
Definition TestCase.py:98
_testCaseName
The name of the current test case.
Definition TestCase.py:96