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
19# -- local imports -----------------------------------------------------------------------------{{{-
20import mevis
21from .TestCase import TestCase
22from TestSupport.TestHelper import TestHelper
23
24# ----------------------------------------------------------------------------------------------}}}-
25
26
27# -- class GenericTestCase ---------------------------------------------------------------------{{{-
28
30 # -- def __init__ ----------------------------------------------------------------------------{{{-
31
32 def __init__(self, testCaseName, moduleName=None):
33 self._testCaseType_testCaseType = "GenericTestCase"
34 self._moduleName = moduleName
35 TestCase.__init__(self, testCaseName)
36
37 # --------------------------------------------------------------------------------------------}}}-
38
39 # -- def run ---------------------------------------------------------------------------------{{{-
40
41 def run(self, xmlNode):
42 if not self._moduleName:
43 raise Exception("No module name set for test %s." % (self._testCaseName_testCaseName))
44 self._testHelper.setModuleName(self._moduleName)
45 TestCase.run(self, xmlNode)
46 self._testHelper.setModuleName(None)
47
48 # --------------------------------------------------------------------------------------------}}}-
49
50 # -- def __testModule ------------------------------------------------------------------------{{{-
51
54 def __testModule(self, moduleName):
55 if "testModule" in self._ctx.callableFunctions():
56 return self._ctx.call(
57 "testModule",
58 [
59 moduleName,
60 ],
61 )
62 return True
63
64 # --------------------------------------------------------------------------------------------}}}-
65
66 # -- def getName -----------------------------------------------------------------------------{{{-
67
68 def getName(self):
69 return "%s::%s" % (self._testCaseName_testCaseName, self._moduleName)
70
71 # --------------------------------------------------------------------------------------------}}}-
72
73 # -- def getModulesToTest --------------------------------------------------------------------{{{-
74
75 def getModulesToTest(self, moduleList, packageList):
76 availableModuleList = []
77
78 for packageIdentifier in packageList:
79 availableModuleList.extend(mevis.MLAB.allModulesForPackageIdentifier(packageIdentifier))
80
81 # Testing myself wouldn't be a good idea (recursive adding of module is not supported).
82 testerName = TestHelper.getInstance().getGlobalContext().name
83 if testerName in availableModuleList:
84 availableModuleList.remove(testerName)
85
86 modulesToTest = []
87 modulesNotToTest = []
88 for moduleName in moduleList:
89 if moduleName in availableModuleList:
90 if self.__testModule(moduleName):
91 modulesToTest.append(moduleName)
92 else:
93 modulesNotToTest.append(moduleName)
94 return modulesToTest, modulesNotToTest
95
96 # --------------------------------------------------------------------------------------------}}}-
97
98
99# ----------------------------------------------------------------------------------------------}}}-
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:90
_testHelper
The instance of the TestHelper singleton.
Definition TestCase.py:95
_ctx
The TestCase's context.
Definition TestCase.py:93
_testCaseType
The type of the test case.
Definition TestCase.py:100
_testCaseName
The name of the current test case.
Definition TestCase.py:98