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