TestCenter Reference
Formal.py
Go to the documentation of this file.
1 #
2 # Copyright 2016, 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 import os
12 import re
13 from TestSupport import Base
14 from mevis import MLABTestCaseDatabase
15 
17  # ignore the deprecation warnings only if this module is deprecated
18  if isModuleToBeRemoved(modInfo):
19  regExp = re.compile(r"^Network\‍(\d+\‍)\sThis\smodule\stype\sis\sdeprecated\sand\swill\sbe\sremoved.*$")
20  Base.expectWarning(func, warningRegExp=regExp)
21  else:
22  func()
23 
24 def isModuleToBeRemoved(moduleInfo):
25  for key in moduleInfo:
26  if key.lower() == "group":
27  return "toberemoved" in moduleInfo[key].lower()
28  return False
29 
31  disableScreenshots = 'MLAB_TC_NO_SCREENSHOTS' in os.environ
32  return disableScreenshots
33 
34 def getList(modInfo, itemListName): # --------------------------------------{{{-
35  return modInfo[itemListName] if type(modInfo[itemListName]) in (tuple, list) else (modInfo[itemListName],)
36 
37 def getListFromString(modInfo, itemListName):
38  string = modInfo[itemListName]
39  if "," in string:
40  listParts = [x.strip() for x in string.split(",")]
41  else:
42  listParts = string.split()
43  return listParts
44 
45 def isTestInSamePackage(testName, packageName): # --------------------------{{{-
46  testInfo = MLABTestCaseDatabase.testCaseInfo(testName)
47  return len(testInfo) > 0 and testInfo['package'] == packageName
48 # --------------------------------------------------------------------------}}}-
49 
50 def initTestDataBase(): # --------------------------------------------------{{{-
51  """ Initializes the test case data base if it is not
52  already initialized."""
53  if not MLABTestCaseDatabase.areTestCasesLoaded():
54  MLABTestCaseDatabase.loadTestCases()
55 # --------------------------------------------------------------------------}}}-
def getList(modInfo, itemListName)
Definition: Formal.py:34
def initTestDataBase()
Definition: Formal.py:50
def areScreenshotsDisabledByEnvironmentVariable()
Definition: Formal.py:30
def isModuleToBeRemoved(moduleInfo)
Definition: Formal.py:24
def runFunctionButIgnoredDeprecationWarnings(func, modInfo)
Definition: Formal.py:16
def isTestInSamePackage(testName, packageName)
Definition: Formal.py:45
def getListFromString(modInfo, itemListName)
Definition: Formal.py:37