TestCenter Reference
Formal.py
Go to the documentation of this file.
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
11import os
12import re
13from TestSupport import Base
14from mevis import MLABTestCaseDatabase, MLABPackageManager
15
16
18 # ignore the deprecation warnings only if this module is deprecated
19 if isModuleToBeRemoved(modInfo):
20 regExp = re.compile(r".* This module type is deprecated and will be removed in the next major release:.*$")
21 Base.expectWarning(func, warningRegExp=regExp)
22 else:
23 func()
24
25
26def isModuleToBeRemoved(moduleInfo):
27 for key in moduleInfo:
28 if key.lower() == "group":
29 return "deprecated" in moduleInfo[key].lower()
30 return False
31
32
34 disableScreenshots = "MLAB_TC_NO_SCREENSHOTS" in os.environ
35 return disableScreenshots
36
37
38def getList(modInfo, itemListName): # --------------------------------------{{{-
39 return modInfo[itemListName] if type(modInfo[itemListName]) in (tuple, list) else (modInfo[itemListName],)
40
41
42def getListFromString(modInfo, itemListName):
43 string = modInfo[itemListName]
44 if "," in string:
45 listParts = [x.strip() for x in string.split(",")]
46 else:
47 listParts = string.split()
48 return listParts
49
50
51def isTestInAllowedPackage(testName, packageName):
52 modulePackage = MLABPackageManager.packageByIdentifier(packageName)
53 testInfo = MLABTestCaseDatabase.testCaseInfo(testName)
54 return len(testInfo) > 0 and modulePackage and not modulePackage.shouldNotDependOnPackage(testInfo["package"])
55
56
57def initTestDataBase(): # --------------------------------------------------{{{-
58 """Initializes the test case data base if it is not
59 already initialized."""
60 if not MLABTestCaseDatabase.areTestCasesLoaded():
61 MLABTestCaseDatabase.loadTestCases()
62
63
64# --------------------------------------------------------------------------}}}-
runFunctionButIgnoredDeprecationWarnings(func, modInfo)
Definition Formal.py:17
areScreenshotsDisabledByEnvironmentVariable()
Definition Formal.py:33
getListFromString(modInfo, itemListName)
Definition Formal.py:42
isModuleToBeRemoved(moduleInfo)
Definition Formal.py:26
isTestInAllowedPackage(testName, packageName)
Definition Formal.py:51
getList(modInfo, itemListName)
Definition Formal.py:38