TestCenter Reference
TestCaseGeneric.py
Go to the documentation of this file.
1 #
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 
11 
13 
14 # -- system imports ----------------------------------------------------------------------------{{{-
15 import xml.etree.cElementTree as etree
16 # ----------------------------------------------------------------------------------------------}}}-
17 
18 # -- local imports -----------------------------------------------------------------------------{{{-
19 import mevis
20 from .TestCase import TestCase
21 from 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_testCaseType = 'GenericTestCase'
31  self._moduleName_moduleName = moduleName
32  TestCase.__init__(self, testCaseName)
33  # --------------------------------------------------------------------------------------------}}}-
34 
35  # -- def run ---------------------------------------------------------------------------------{{{-
36 
37  def run (self, xmlNode):
38  if not self._moduleName_moduleName:
39  raise Exception("No module name set for test %s." % (self._testCaseName_testCaseName))
40  self._testHelper_testHelper.setModuleName(self._moduleName_moduleName)
41  TestCase.run(self, xmlNode)
42  self._testHelper_testHelper.setModuleName(None)
43 
44  # --------------------------------------------------------------------------------------------}}}-
45 
46  # -- def __testModule ------------------------------------------------------------------------{{{-
47 
50  def __testModule (self, moduleName):
51  if "testModule" in self._ctx_ctx.callableFunctions():
52  return self._ctx_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_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__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.
def run(self, xmlNode)
Prior to running the actual test the module name is set to the result node.
def __init__(self, testCaseName, moduleName=None)
The default constructor.
def getName(self)
Return the name of the test case.
def getModulesToTest(self, moduleList, packageList)
Get the list of modules to test.
The superclass for the different test case categories.
Definition: TestCase.py:88